目录结构:
project
├── info.json
├── run.py
└── static
└── readme.txt
# 直接返回static目录下的文件内容
@app.route('/readme.txt')
def hi():
return redirect(url_for('static',filename='readme.txt'))
# 若要返回根目录下的文本文件,如info.json则:
@app.route('/<path>')
def info(path):
resp = make_response(open(path).read())
resp.headers["Content-type"]="application/json;charset=UTF-8"
return resp
--END--