欢迎关注我👆,收藏下次不迷路┗|`O′|┛ 嗷~~
以下是一个示例,展示了如何在 Flask 中创建一个路由,该路由发送一个文件,并在响应头中添加一个自定义的字符串:
from flask import Flask, send_file, make_response
app = Flask(__name__)
@app.route('/get-image-with-data')
def get_image_with_data():
image_path = 'path/to/your/image.jpg'
response = make_response(send_file(image_path, mimetype='image/jpeg'))
response.headers['X-Custom-Data'] = 'your_string_here'
return response
if __name__ == '__main__':