#πŸ”’ Flask view function returning

5 messages Β· Page 1 of 1 (latest)

worthy wind
#
@bp.route("/create_account", methods=["POST"])
def create_account() -> None:
    if request.method == "POST":
        username: str = request.args.get("username")
        password: str = request.args.get("password")
        db = get_db()
        user_id: str = str(uuid4())
        acc_data: tuple = (user_id, username, hash_p(password))
        db.execute("INSERT INTO Acc_Data (acc_id, username, h_pass) VALUES (?, ?, ?)", acc_data)
        db.commit()

This is my view function and it works but then flask raises a type error raise TypeError( r returned None or ended without a return statement. TypeError: The view function for 'auth.create_account' did not return a valid response. The function either returned None or ended without a return statement.

Why does it have to return something if its a post request?

main marshBOT
#

@worthy wind

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

worthy wind
#

!close

main marshBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.