[英]Flask POST endpoint not receiving arguments with curl
I have this simple flask app with one endpoint and I am trying to receive data from a POST request in curl.我有一个带有一个端点的简单 flask 应用程序,我正在尝试从 curl 中的 POST 请求接收数据。 This is my code:这是我的代码:
from flask import Flask
from flask import request
def create_app():
app = Flask(__name__)
@app.route("/shipment", methods=["POST"])
def hello_world():
if "start" in request.args:
return "arg found"
else:
return "missing args"
return app
curl -X POST 127.0.0.1:5000/shipment -d start="test"
request.args
can only retrieve key/value pair in the URL. request.args
只能检索 URL 中的键/值对。 You need to check request.values
instead.您需要改为检查request.values
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.