import cherrypy from .db import DBPoolManager class Server(): def __init__(self,dbpool:DBPoolManager): cherrypy.engine.subscribe("newpage",self.registerpage) self.pages={} self.dbpool=dbpool def registerpage(self,path,content): self.pages[path]=content @cherrypy.expose def index(self,quote="nothing"): return "Index" @cherrypy.expose(["style.css"]) def style(self): from .html import style_css return style_css @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)