Flask restful 正在执行 GET 而不是 POST

Flask restful is doing GET instead of POST

我有一个简单的 flask 和 flask_restful 内置 python 的应用程序,如图所示:

from flask import Flask
from flask_restful import Api, Resource

app = Flask(__name__)
api = Api(app)


class Route(Resource):
    def post(self):
        return "Posted"


api.add_resource(Route, '/')

if __name__ == '__main__':
    app.run(debug=True)

但是,当我 运行 这个应用程序并导航到 link 时,我收到此消息:

{
    "message": "The method is not allowed for the requested URL."
}

我的烧瓶输出如下所示:

 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 691-936-340
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [11/Jun/2021 10:07:33] "GET / HTTP/1.1" 405 -

我的 API 似乎在应该进行 post 时进行了 get 调用。有什么建议吗?

当您通过浏览器导航时,它会发送 GET 请求,这就是您获得
的原因 {"message": "The method is not allowed for the requested URL." }
我尝试通过 Postman 发送 POST 请求并返回有效响应。