![](/img/trans.png)
[英]How to send image with form data in test case with unittest in flask application?
[英]How to send application/json data with image file in python flask?
我正在使用 send_from_directory function。
@app.route('/get_data',methods=["GET"])
def get_data():
path = os.path.join(app.config['UPLOAD_FOLDER'], 'uploads')
return send_from_directory(path,"cat.jpg")
HTTP 響應應以一種類型的數據進行響應。 這取決於你的客戶是做什么的。
例如,您可以將 json 返回給客戶端,其中包含圖像的 URL,然后客戶端應該獲取該圖像。
Another option is to return an image and return the json data in an HTTP header, or as the first option - have an http header that contains a URL for the JSON data, and make the client fetch the JSON data later.
祝你好運:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.