diff options
Diffstat (limited to 'src/acit/web.py')
| -rw-r--r-- | src/acit/web.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/acit/web.py b/src/acit/web.py index 15cbe46..7c6c054 100644 --- a/src/acit/web.py +++ b/src/acit/web.py @@ -4,15 +4,26 @@ import cherrypy class Server(): def __init__(self): - pass + 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 "<html><body><h1>Hi</h1><p>you said %s</p></body></html>" %quote + return "Index" @cherrypy.expose - def default(self,*path,**kwargs): - return "Hello world" + 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) |
