I have the following code:
@app.route("/", methods=["GET", "POST"])
def login():
if request.method == "GET":
return render_template("login.html")
elif request.method == "POST":
username, password = request.form.get("username"), request.form.get("password")
if validate_login(username, password):
return redirect("/home.html")
else:
return render_template("login.html", login_message="Invalid username or password!")
with the following home.html
file:
{% extends "layout.html" %}
{% block body %}
Hello {{ username }}, your password is {{ password }}!
{% endblock %}
The point here is that I am finding some ways to pass in variables to home.html
using the redirect
function (just like the last line of the code render_template
), but after some intense google searches, I still can’t find a way to do so. Do anyone know how to do this?