i'm making a sign up page in flask but when i press submit it doesn't redirect to the home page
from flask import Flask, redirect, url_for, render_template, request
app = Flask(__name__)
@app.route('/', methods = ['GET', 'POST'])
def login():
if request == 'POST':
input1 = request.form.get("input1")
input2 = request.form.get("input2")
return redirect(url_for("home"))
return render_template('lo.html')
@app.route('/home', methods = ['GET','POST'])
def home():
return render_template('ho.html')
if __name__ == "__main__":
app.run(debug=True)
i have no idea why it doesn't work can someone help me?
CodePudding user response:
Did you visit the “/“ path in browser? That’s “GET” method, not match your “POST” method. In addition, you should use if request.method == 'POST':
to check the request method in flask.
Try to remove the condition, it may work as you expected.