import cherrypy class Server(): def __init__(self): cherrypy.engine.subscribe("newpage",self.registerpage) self.pages={} def registerpage(self,path,content): self.pages[path]=content @cherrypy.expose def index(self,quote="nothing"): return "Index" @cherrypy.expose def default(self,*pathlist,**kwargs): from os.path import normpath path=normpath("/".join(pathlist)) if path in self.pages: return self.pages[path] else: from .html import notfound cherrypy.response.status=404 return notfound.format(path=path)