blob: 7c6c05411365c475586803145e0b1915b43c5143 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
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)
|