原图如下
代码如下
from flask import Flask, request, make_response
from datetime import datetime
import os
app = Flask(__name__)
IMG_PATH = "F:\pycharm/feature_match/4.jpg"
@app.route('/display/img/<string:filename>', methods=['GET'])
def display_img(filename):
request_begin_time = datetime.today()
print("request_begin_time", request_begin_time)
if request.method == 'GET':
image_data = open(IMG_PATH, "rb").read()
response = make_response(image_data)
response.headers['Content-Type'] = 'image/jpg'
return response
else:
pass
if __name__ == '__main__':
app.run(host='10.16.55.26', port=5001)
然后通过网页打开http://10.16.55.26:5001/display/img/4.jpg(10.16.55.26为自己的IP地址)
效果如下