[英]Flask api endpoint only passes first arguement
我在端点上使用curl
http://0.0.0.0:5001/event/email/?event_type=open&email_type=questions
我得到的结果是
{
"email_type": null,
"event_type": "open"
}
为什么我会为email_type
获得null
? 我怀疑这与 Flask 如何处理&
有关?
我的部分代码如下:
from flask import Flask, request
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class EmailOpen(Resource):
def get(self):
email_type = request.args.get("email_type")
event_type = request.args.get("event_type")
ad_id = request.args.get("ad_id")
# print(event_type,email_type)
if not ad_id:
return {"event_type":event_type,"email_type":email_type}
return {"event_type":event_type,"email_type":email_type,"ad_id":ad_id}
api.add_resource(EmailOpen, '/event/email/')
我查找了有类似问题的人,但他们似乎与我的情况不完全匹配
Bash 必须以不同的方式解释事物,添加""
有效。
curl "http://0.0.0.0:5001/event/email/?event_type=open&email_type=questions"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.