method not allowed error in flask

后端 未结 1 934
[愿得一人]
[愿得一人] 2020-12-19 10:38

I am getting this error when I try to submit a request.

Method Not Allowed

The method is not allowed for the requested URL.

And here is my

相关标签:
1条回答
  • 2020-12-19 11:27

    You are posting to the entry() function, while your entry_post() function listens to a different route; it is registered to only listen to /data, not /:

    @app.route("/data", methods=['POST'])
    def entry_post():
    

    The / route doesn't accept POST, by default only GET, HEAD and OPTIONS are allowed.

    Adjust your form accordingly:

    <form action="/data" autocomplete="on" method="POST">
    

    Take into account that Flask does not reload your source unless you enable debugging:

    app.run(debug=True)
    
    0 讨论(0)
提交回复
热议问题