POST 请求未被定向到 Flask 中的 POST 路由
POST request is not being directed to POST route in Flask
我正在使用 Flask 开发网络应用程序。
我有两条路线:
@app.route("/<random_id>", methods = ['GET'])
def random_url(random_id):
return "GET"
@app.route("/<random_id>", methods = ['POST'])
def random_url_post(random_id):
return "POST"
当我使用 GET 访问它时,我收到了“GET”,但是当我尝试使用 POST 请求时,它失败了:
root@ubuntu:~# curl http://localhost:1337/a
GET
root@ubuntu:~# curl -xPOST http://localhost:1337/a
curl: (5) Could not resolve proxy: POST
curl: (5) Could not resolve proxy: POST
这可能是什么原因?
-x
是代理参数。您应该使用大写 -X
我正在使用 Flask 开发网络应用程序。
我有两条路线:
@app.route("/<random_id>", methods = ['GET'])
def random_url(random_id):
return "GET"
@app.route("/<random_id>", methods = ['POST'])
def random_url_post(random_id):
return "POST"
当我使用 GET 访问它时,我收到了“GET”,但是当我尝试使用 POST 请求时,它失败了:
root@ubuntu:~# curl http://localhost:1337/a
GET
root@ubuntu:~# curl -xPOST http://localhost:1337/a
curl: (5) Could not resolve proxy: POST
curl: (5) Could not resolve proxy: POST
这可能是什么原因?
-x
是代理参数。您应该使用大写 -X