cryptonas-branches/pythonrewrite/bin2/CryptoBoxWebserver.py

40 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python2.4
import os
import CryptoBoxWebserverSites
try:
import cherrypy
except:
print "Could not import the cherrypy module! Try 'apt-get install python-cherrypy'."
sys.exit(1)
class CryptoBoxWebserver:
'''this class starts the cherryp webserver and serves the single sites'''
def __init__(self):
cherrypy.root = CryptoBoxWebserverSites.CryptoBoxWebserverSites()
#expose static content:
#I currently have no idea how to cleanly extract the stylesheet path from
#the config object without an extra CryptoBox.CryptoBoxProps instance.
#perhaps put config handling into a seperate class in CryptoBox.py?
# [l] why do we need to map the css manually? Shouldn't the whole
# www-data path be accessible anyway?
'''
cherrypy.config.configMap.update(
{
"/cryptobox.css": {
"staticFilter.on" : True,
"staticFilter.file": os.path.abspath("../www-data/cryptobox.css" )
}
})
'''
def start(self):
cherrypy.config.update(file = "cryptoboxwebserver.conf")
cherrypy.server.start()
if __name__ == "__main__":
cbw = CryptoBoxWebserver()
cbw.start()