bev-a-tron / MyFlaskTutorial

A Flask Tutorial for people who don't know any web programming. Actually, it would be helpful to know static HTML, also Python.
343 stars 202 forks source link

Fix use of Flask's redirect #12

Closed iwangu closed 10 years ago

iwangu commented 10 years ago

Currently, code seems to result in "405 Method Not Allowed" HTTP Response (on Chrome), when one submits the 'How many eyes do you have?' question. I see two ways to fix this.

First, call redirect('/usefulfunction_lulu', code=307) instead of redirect('/usefulfunction_lulu'). See more about the underlying issue here: http://stackoverflow.com/questions/15473626/make-a-post-request-while-redirecting-in-flask

Second, omit the "methods=['POST']" in @app_lulu.route('/usefulfunction_lulu'). I suggest this, because it is consistent with 7_finale.rst, in which @app_lulu.route('/main_lulu') also does not restrict on POST.

bev-a-tron commented 10 years ago

Hey Iwangu! Sorry it has taken me so long to look at this! I see the Error 405 you were getting with application_lulu2.py. (application_lulu.py is working fine.) I cloned your fork, and it doesn't seem like your version is working, so I'm hesitant to merge your pull request! I'm going to look at this a little more, and then possibly just delete the application_lulu2.py file. Thanks for contributing to the Flask tutorial! :o)

bev-a-tron commented 10 years ago

One of the examples really is broken It turns out it used to say ['GET', 'POST'], and somebody submitted a pull request to remove the 'GET'. I'm going to add that line back, instead of deleting the GET/POST. Since people doing the tutorial are beginners, there's no need to confuse them by omitting it entirely! I'll be sure to credit you in the commit message. Thanks so much! :)

iwangu commented 10 years ago

no problem. thank you for the great tutorial!

bev-a-tron commented 10 years ago

You're welcome! Glad you found it useful! :)

Sent from my iPhone

On Sep 4, 2014, at 10:59 PM, iwangu notifications@github.com wrote:

no problem. thank you for the great tutorial!

— Reply to this email directly or view it on GitHub.