Dino De Castro
Sep 1, 2018 · 1 min read

Thanks DD for another concise tutorial on Flask!

Also, I think we need to use render_template on login.html so that we are initially on the login page:

from flask import Flask, request, redirect, url_for, render_templateapp = Flask(__name__)@app.route('/login', methods = ['POST', 'GET'])
def login():
if request.method == 'POST':
user = request.form['nm']
return redirect(url_for('success', name = user))
else:
user = request.args.get('nm')
return render_template('login.html')
@app.route('/success/<name>')
def success(name):
user = name
return f"Welcome {name}"

Cheers!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade