我正在开发一个使用Flask的SAAS应用程序,我希望用户能够创建/上传/使用他们自己的自定义模板。这是我的目录结构是怎样现在:Flask:如何从模板目录提供静态文件?
/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。否则我只是不知道你的意思。 –
这里'/ flaskapp/something'是指目录而不是URL。 – anujkk