
[英]Use Flask to serve both static CSS and static video files
[英]Serve both React bundle and static files with Flask?
我正在使用 Flask/Gunicorn 服务器来为我的 React 构建和 static 文件提供服务。 两者都存储在同一个 /static/ 文件夹中,如下所示:
app = Flask(__name__, static_folder='./static', static_url_path='/')
我可以用下面的代码做任何一个:
@app.route('/')
def index():
return app.send_static_file('index.html')
@app.route('/static/<path:path>')
def send_mp3(path):
return send_from_directory('static', path)
当我有 2) 处于活动状态时,我无法将 index.html 提供给新客户端,但可以提供 mp3 文件(使用缓存页面测试)。
当我 1) 处于活动状态时,我无法提供 mp3 文件。
我怎样才能两者兼得?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.