app.py
from flask import Flask, render_template, request, jsonify app = Flask(__name__) @app.route('/') def home(): return render_template('index.html') if __name__ == '__main__': app.run('0.0.0.0', port=5000, debug=True)índice.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="static/index.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="scripts/jquery-1.10.2.js"></script> <script src="/jquery/index.js"></script> <title>Title</title> <script> </script> </head> <body> <h1>Hello World!</h1> </body> </html>índice.js
$(function () { $(document).ready(function () { alert('Hello World'); }); }Creo que estoy haciendo algo mal. Quiero mostrar un mensaje cuando el documento esté listo. Incluso si ejecuto app.py, la alerta no aparece.
¿Has intentado incrustar el script directamente dentro del código html?
... <script>your script code</script> </body> </html>Si eso funciona, la ruta relativa a src="/jquery/index.js" podría no ser correcta.
¿Revisó los archivos de registro de Apache (o cualquier servidor web que ejecute) en errores relacionados con index.js?