【发布时间】:2012-12-09 17:51:56
【问题描述】:
我正在使用 Flask 开发一个 SAAS 应用程序,我希望用户能够创建/上传/使用他们自己的自定义模板。这就是我现在的目录结构:
/flaskapp
/application.py
/static
/style.css
/templates (site & admin templates goes here)
/hello.html
/userdata
/user1
/template1
hello.html
/template2
hello.html
/user2
/template1
hello.html
/template2
hello.html
我可以使用通过这个 * 问题找到的解决方案为用户指定的模板提供服务:How to dynamically select template directory to be used in flask? 但我如何从模板目录提供静态文件。而不是从/flaskapp/static/ 提供静态文件,我想使用/flaskapp/userdata/<user>/<current-template>/static/ 目录提供静态文件,该目录将在运行时动态确定。如何做到这一点?
【问题讨论】:
-
/flaskapp/something是指 URL 还是目录名称?请每次都说:用该目录中的静态文件提供此 URL。否则我就是不明白你的意思。 -
/flaskapp/something指的是目录而不是 URL。