English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
/ student.html /
result.html
-
# Dateiname: example.py # Copyright: 2020 Durch w3codebox # Autor durch: de.oldtoolbag.com # Datum: 2020-08-08 / /result def result(): if request.method == 'POST': result = request.form return render_template("result.html", result=result) if __name__ == '__main__': app.run(debug=True)
Hier sind student.html des HTML-Skripts.
# Dateiname: example.py # Copyright: 2020 Durch w3codebox # Autor durch: de.oldtoolbag.com # Datum: 2020-08-08 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Flask Beispiel</title> </head> <body> <form action="http://localhost:5000/result" method="POST"> <p>Name <input type="text" name="Name"> /></p> <p>Physikalische Punkte: <input type="text" name="Physics"> /></p> <p>Chemische Punkte: <input type="text" name="Chemistry"> /></p> <p>Mathematische Bruch: <input type = "text" name = "Mathematics"}} /></p> <p><input type = "submit" value = "Absenden" /></p> </form> </body> </html>
Das Template-Code (result.html) wird unten angegeben -
# Dateiname: example.py # Copyright: 2020 Durch w3codebox # Autor durch: de.oldtoolbag.com # Datum: 2020-08-08 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Flask Beispiel</title> </head> <body> <table border = 1> {% for key, value in result.items() %} <tr> <th> {{ key }} <//th> <td> {{ value }} <//td> </tr> {% endfor %} </table> </body> </html>
Führen Sie das Python-Skript aus und geben Sie die URL im Browser ein => http://localhost:5000/ . Das Ergebnis ist wie folgt -
Wenn Sie auf Absendenwenn Sie auf den Button klicken, werden die Formulardaten in Form eines HTML-Tabs dargestellt result.html wie folgt -