To set it up more,correct and fix error.
Capitale letters in method == 'POST'
Have remove GET to avoid to confusion.
foo\
app.py
templates\
index.htm
app.py
from flask import Flask,redirect,url_for,request,render_template
app = Flask (__name__)
@app.route('/')
def my_form():
return render_template("index.html")
@app.route('/suc/<name>')
def suc(name):
return "hello Boss %s" % name
@app.route('/login', methods=['POST'])
def log():
if request.method == 'POST':
user = request.form['nm']
return redirect(url_for('suc', name=user))
if __name__ == '__main__' :
app.run(debug=True)
index.html
<html>
<body>
<form action = "http://localhost:5000/login" method="post">
<p>Enter Name:</p>
<p><input type="text" name="nm" /></p>
<p><input type="submit" value="submit" /></p>
</form>
</body>
</html>