PPM2: select
This commit is contained in:
54
Praktikum2/ppm2/server.py
Normal file
54
Praktikum2/ppm2/server.py
Normal file
@ -0,0 +1,54 @@
|
||||
# coding:utf-8
|
||||
|
||||
import os.path
|
||||
import cherrypy
|
||||
|
||||
from app import templates, category, choice, eval
|
||||
|
||||
#----------------------------------------------------------
|
||||
def main():
|
||||
#----------------------------------------------------------
|
||||
|
||||
# aktuelles Verzeichnis ermitteln, damit es in der Konfigurationsdatei als
|
||||
# Bezugspunkt verwendet werden kann
|
||||
try: # aktuelles Verzeichnis als absoluter Pfad
|
||||
currentDir_s = os.path.dirname(os.path.abspath(__file__))
|
||||
except:
|
||||
currentDir_s = os.path.dirname(os.path.abspath(sys.executable))
|
||||
cherrypy.Application.currentDir_s = currentDir_s
|
||||
|
||||
configFileName_s = 'server.conf' # im aktuellen Verzeichnis
|
||||
if os.path.exists(configFileName_s) == False:
|
||||
# Datei gibt es nicht
|
||||
configFileName_s = None
|
||||
|
||||
# autoreload und timeout_Monitor hier abschalten
|
||||
# für cherrypy-Versionen >= "3.1.0" !
|
||||
cherrypy.engine.autoreload.unsubscribe()
|
||||
cherrypy.engine.timeout_monitor.unsubscribe()
|
||||
|
||||
# Standardverhalten, Berücksichtigung der Konfigurationsangaben im configFile
|
||||
cherrypy.tree.mount(
|
||||
None, '/', configFileName_s
|
||||
)
|
||||
|
||||
cherrypy.tree.mount(
|
||||
category.Category(), '/category', {'/': {'request.dispatch': cherrypy.dispatch.MethodDispatcher()}}
|
||||
)
|
||||
cherrypy.tree.mount(
|
||||
choice.Choice(), '/choice', {'/': {'request.dispatch': cherrypy.dispatch.MethodDispatcher()}}
|
||||
)
|
||||
cherrypy.tree.mount(
|
||||
eval.Eval(), '/eval', {'/': {'request.dispatch': cherrypy.dispatch.MethodDispatcher()}}
|
||||
)
|
||||
cherrypy.tree.mount(
|
||||
templates.Templates(), '/templates', {'/': {'request.dispatch': cherrypy.dispatch.MethodDispatcher()}}
|
||||
)
|
||||
|
||||
cherrypy.engine.start()
|
||||
cherrypy.engine.block()
|
||||
|
||||
#----------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
#----------------------------------------------------------
|
||||
main()
|
Reference in New Issue
Block a user