Python 来自不同路径的CherryPy静态内容

Python 来自不同路径的CherryPy静态内容,python,web-applications,cherrypy,httpserver,Python,Web Applications,Cherrypy,Httpserver,我读过一些类似的问答 但是,我不知道如何通过不同的路径共享 我有以下课程: 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_he

我读过一些类似的问答

但是,我不知道如何通过不同的路径共享

我有以下课程:

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"
从/help访问css时,我遇到了404错误。我必须为类中要为css文件提供服务的每个方法添加[path]条目吗?或者我必须使用[global]标签,尽管我可能不想在其他应用程序中使用它?应用程序配置和路径配置条目之间有什么区别?直到知道之前,我一直认为这是一个有两条路径的应用程序(“/”和“/帮助”)

我通过的配置如下:

# Configuration
import os.path
tutconf = os.path.join(os.path.dirname(__file__), 'myconf.conf')
cherrypy.quickstart(root, config=tutconf)
两个网页加载CSS的方式相同(实际上是相同的代码):


问题在于html本身使用绝对URL,当内容相同时,没有理由使用相对URL,而不是:

<link rel="stylesheet" type="text/css"  href="css/style201306.css" />

这个问题在ServerFault中被标记为离题。有人建议我把它搬到这里来。就是这样。
<link rel="stylesheet" type="text/css"  href="css/style201306.css" />
<link rel="stylesheet" type="text/css"  href="/css/style201306.css" />
/help/css/style201306.css