Issue
I get this error when I try to open the sign-up page. Also "if request.method == ‘POST’:" part of code is highlighted.
from typing import Text
from flask import Blueprint, render_template, request, flash
from werkzeug.wrappers import request
auth = Blueprint('auth', __name__)
@auth.route('/login', methods=['GET', 'POST'])
def login():
return render_template("login.html", boolean=True)
@auth.route('/logout')
def logout():
return "<p>logout</p>"
@auth.route('/sign-up', methods=['GET', 'POST'])
def sign_up():
if request.method == 'POST':
email = request.form.get('email')
firstName = request.form.get('firstName')
password1 = request.form.get('password1')
password2 = request.form.get('password2')
return render_template("sign_up.html")
Solution
The problem is that you’re importing a request
module two times (one time from flask, the other time from werkzeug). One workaround is to rename the second import, i.e.,
from werkzeug.wrappers import request as werkzeug_request
Then, whenever you need that module, use werkzeug_request
.
But you probably don’t even want that import, so I would suggest to remove the import from werkzeug and get the form data as follows:
email = request.form['email']
Answered By – Leonard
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0