test1.txt
Hello world!
from flask import *
app = Flask(__name__)
# 转发
@app.route('/test')
def test():
return app.send_static_file('test1.txt')
# 重定向
@app.route('/abc')
def abc():
return redirect('/static/test1.txt')
if __name__ == '__main__':
app.run()
* Serving Flask app "__main__" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [31/Mar/2020 16:09:03] "GET /test HTTP/1.1" 404 -
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。