请求标头(通过print request.headers
):
Origin: null
Content-Length: 15
User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Mobile Safari/537.36
Connection: keep-alive
Host: <host>
Accept: application/json
Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7
Content-Type: application/json
Accept-Encoding: gzip, deflate
[1B blob data]
print request.from
提供ImmutableMultiDict([])
print request.args
提供ImmutableMultiDict([])
print request.data
提供[object Object]
print request.is_json
提供True
....
在致电request.get_json()
后,会立即回复404
如何获取我的帖子数据?
使用cross_origin
装饰器调用flask函数调用
更新:
功能代码:
@app.route('/users', methods=['POST'])
@cross_origin()
def register():
print request.headers
print '~~~~~~~~'
print request.form
print request.args
#print request.data
print request.is_json
print request.accept_mimetypes
print request.get_json()
return '', 200
UPDATE2:
当我通过终端中的http发送帖子时,它正常工作并提供内容长度:16,但是当我通过axios发送帖子时,它会给出400和内容长度:15。其他标题相同。
答案 0 :(得分:1)
看起来像axios的问题,它不能把dict作为帖子数据,所以我在反应中传递带 input {
kafka {
topics => [
...
]
bootstrap_servers => "${KAFKA_URL}"
codec => "json"
}
}
filter {
...
}
output {
elasticsearch {
index => "logstash-%{organizationId}"
hosts => ["${ELASTICSEARCH_URL}"]
codec => "json"
}
stdout { codec => json }
}
的参数,并在烧瓶中传递JSON.stringify(data_dict)