@app.route('/<date>/<username>/<path:filename>')
@login_required
@nocache
def custom_static(filename, username, date):
path = os.path.join(app.config['CUSTOM_STATIC_PATH'],"username", username, date)
print "Path: {}".format(path)
if os.path.isfile(os.path.join(path, filename)):
return send_from_directory(path, filename)
else:
print "File does not exist: {}".format(filename)
return
错误:
Path: ./DataWebserver/username/js/static
File does not exist: bootstrap-datepicker.min.js
enter code here
有趣的是,如果我的路线只有2个变量,如
,它就可以工作@app.route('/<date>/<username>/')
而不是
@app.route('/<date>/<username>/<path:filename>')
答案 0 :(得分:0)
我进一步深入挖掘并意识到原始API路由端点不明确,并且还映射了css / js路径。
@app.route('/<date>/<username>/<path:filename>')
// Static
/static/css/file.css
/static/js/file.js
// User Content
/2017-02-06/my_user_name/my_file
我最后的解决方法是使我的API路由的端点名称不是动态的
@app.route('/file/<date>/<username>/<path:filename>')