I want to write a view that asks for some input then returns it as uppercase. I followed the instructions in Send Data from a textbox into Flask?.
The app is hosted using Phusion Passenger via cPanel at example.com/form
. When I click Submit, I am sent to example.com
. Nothing happens to the text on example.com/form
before I am redirected.
What am I doing wrong? Why am I being redirected?
templates/form.html
<form action="." method="POST">
<textarea name="text"></textarea>
<input type="submit">
</form>
form.py
from flask import Flask, request, render_template
app = Flask(__name__)
@app.route('/')
def form():
return render_template('form.html')
@app.route('/', methods=['POST'])
def form_post():
return request.form['text'].upper()