I've been using python flask as well as html, in order to create a small website, (just as a hobby while I'm off school), I created a form in html, and saved it within the templates folder of the project. I also then added a function within the python script, so when a button is clicked of the webpage it would redirect the user back to the home page (index.html), however when I have tested the webpage and clicked on the button on the webpage (with the flask server running) a "400 bad request" page is shown
Python Code:
@app.route('/test', methods=['POST'])
def test():
#text = request.form['text']
print ("Test page function")
return render_template("index.html")
HTML code: -->
<body>
<h1>Test Page</h1>
<form method="POST">
<input type="submit" name="my-form" value="Send">
</form>
</body>
Aucun commentaire:
Enregistrer un commentaire