我正在開發一個使用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