仅使用带有 Python 的 Flask 服务器,以下获取请求有效:
from flask import Flask, request
app = Flask(__name__)
class Result(Resource):
def get(self):
image_id = request.headers.get('image_id')
api.add_resource(Result, '/results')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=int(os.getenv('PORT', 5000)))
但是,使用 Waitress 时,以下内容不起作用(image_id 为 None):
from waitress import serve
from flask import Flask, request
app = Flask(__name__)
class Result(Resource):
def get(self):
image_id = request.headers.get('image_id')
api.add_resource(Result, '/results')
if __name__ == '__main__':
serve(app, host="0.0.0.0", port=int(os.getenv('PORT', 5000)))
POST 和其他 GET 请求工作正常,只是 GET 带有不起作用的标头。有人有想法么?