@app.route("/static/<filename>")
def get_filename(filename):
with open(r'E:/xxxxx/static/{}'.format(filename),'rb') as f:
fileas = f.read()
resp = Response(fileas,mimetype='application/octet-stream')
if __name__ == "__main__":
app.run(host='127.0.0.1', port='5678',use_reloader=False)
filename是要访问的文件的名称,文件在static文件夹下,完整的访问链接:
http://127.0.0.1:5678/static/ 要访问的文件名称
注意:mimetype决定可以访问文件的类型