WEB/Praktikum3/bt/server.py

77 lines
2.8 KiB
Python
Raw Permalink Normal View History

2017-01-16 23:32:28 +01:00
#coding: utf-8
import os
import cherrypy
from app import application, templates, navigation, projekt, staff, error, eval
#--------------------------------------
def main():
#--------------------------------------
# Get current directory
try:
current_dir = os.path.dirname(os.path.abspath(__file__))
except:
current_dir = os.path.dirname(os.path.abspath(sys.executable))
# disable autoreload and timeout_monitor
cherrypy.engine.autoreload.unsubscribe()
cherrypy.engine.timeout_monitor.unsubscribe()
# Static content config
staticConfig_o = {
'/': {
'tools.staticdir.root': current_dir,
'tools.staticdir.on': True,
'tools.staticdir.dir': './static',
'tools.staticdir.index': './html/index.html',
'request.dispatch': cherrypy.dispatch.MethodDispatcher()
},
'/favicon.ico': {
'tools.staticfile.on': True,
'tools.staticfile.filename': current_dir+'/static/images/favicon.ico'
}
}
staticConfig2_o = {
'/': {
'request.dispatch': cherrypy.dispatch.MethodDispatcher()
}
}
cherrypy.config.update({
'tools.log_headers.on': True,
'tools.sessions.on': False,
'tools.encode.on': True,
'tools.encode.encoding': 'utf-8',
'server.socket_port': 8080,
'server.socket_timeout': 60,
'server.thread_pool': 10,
'server.environment': 'production',
'log.screen': True,
'request.show_tracebacks': False
})
# Request-Handler definieren
cherrypy.tree.mount(application.Application_cl(), '/', staticConfig_o)
cherrypy.tree.mount(templates.Templates_cl(), '/templates', staticConfig2_o)
cherrypy.tree.mount(navigation.Navigation_cl(), '/navigation', staticConfig2_o)
#cherrypy.tree.mount(projekt.Projekt_cl(), '/projekt', staticConfig2_o)
#cherrypy.tree.mount(projekt.ProjektKomponenten_cl(), '/projektkomponenten', staticConfig2_o)
#cherrypy.tree.mount(projekt.Komponente_cl(), '/komponente', staticConfig2_o)
#cherrypy.tree.mount(staff.QsMitarbeiter_cl(), '/qsmitarbeiter', staticConfig2_o)
#cherrypy.tree.mount(staff.SwEntwickler_cl(), '/swentwickler', staticConfig2_o)
#cherrypy.tree.mount(error.KatFehler_cl(), '/katfehler', staticConfig2_o)
#cherrypy.tree.mount(error.KatUrsache_cl(), '/katursache', staticConfig2_o)
#cherrypy.tree.mount(error.Fehler_cl(), '/fehler', staticConfig2_o)
#cherrypy.tree.mount(eval.ProList_cl(), '/prolist', staticConfig2_o)
#cherrypy.tree.mount(eval.KatList_cl(), '/katlist', staticConfig2_o)
# Start server
cherrypy.engine.start()
cherrypy.engine.block()
#--------------------------------------
if __name__ == '__main__':
#--------------------------------------
main()
# EOF