0
我看過一些問答&一個像load-static-content-with-cherrypyCherryPy的不同路徑的靜態內容
但是,我無法弄清楚如何做到這一點通過不同的路徑共享。
我有以下類別:
class Root(Base):
@cherrypy.expose
def index(self):
return self.html_head()+self.header()+"Root"+self.footer()+self.html_end()
@cherrypy.expose
def help(self):
return self.html_head()+self.header()+"HELP"+self.footer()+self.html_end()
而且配置文件是:
[global]
server.socket_host = "127.0.0.1"
server.socket_port = 8080
server.thread_pool = 10
[/]
tools.staticfile.root = "/path/to/app/"
[/css/style201306.css]
tools.staticfile.on = True
tools.staticfile.filename = "css/style201306.css"
當accesing從/幫助我得到了一個404錯誤的CSS。我必須爲我的課程中的每個要爲CSS文件提供服務的方法添加一個[路徑]條目?或者我必須改用[global]標籤,但也許我不想從其他應用程序中使用它?應用程序配置和路徑配置條目有什麼區別?直到知道我正在考慮這個作爲一個應用程序有2條路徑(「/」和「/幫助」)
我傳遞的配置,如:
# Configuration
import os.path
tutconf = os.path.join(os.path.dirname(__file__), 'myconf.conf')
cherrypy.quickstart(root, config=tutconf)
兩個網頁加載CSS以同樣的方式(實際上,是相同的代碼):
css/style201306.css
這個問題已經被標記爲摘在ServerFault中的主題。我被建議在這裏移動它。所以在這裏。 – cantalapiedra