302 Redirection Error Before 200 Success Code In Flask
Solution 1:
You are using Flask's redirect
to issue a redirect which is going to send a 302 response to the client with a Location
header instructing the client to go to /home
instead. Then the client has to issue the request to this new URL where the client finally gets the 200 response code. That is why you are seeing two requests and the 302 and 200 response codes in the server logs.
This particular line is causing the redirect:
return redirect(url_for('home'))
It seems like you expected redirect
to simply render the content of /home
and return that as the response with the original request to /
(e.g. a single 200 response). If that's what you actually want, you could instead use render_template
(or whatever you use in /home
to render your content) to directly render that page. However, I would recommend keeping the redirect behavior as you have it.
Post a Comment for "302 Redirection Error Before 200 Success Code In Flask"