Sammlung
This commit is contained in:
66
Sammlung/Praktikum/4/server.py
Normal file
66
Sammlung/Praktikum/4/server.py
Normal file
@ -0,0 +1,66 @@
|
||||
# coding:utf-8
|
||||
|
||||
import os.path
|
||||
import cherrypy
|
||||
|
||||
from app import topic, discussion, post, login, template
|
||||
|
||||
#----------------------------------------------------------
|
||||
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
|
||||
)
|
||||
|
||||
# Method-Dispatcher für die "Applikation" "topic" vereinbaren
|
||||
cherrypy.tree.mount(
|
||||
topic.Topic_cl(), '/topic', {'/': {'request.dispatch': cherrypy.dispatch.MethodDispatcher()}}
|
||||
)
|
||||
|
||||
# Method-Dispatcher für die "Applikation" "discussion" vereinbaren
|
||||
cherrypy.tree.mount(
|
||||
discussion.Discussion_cl(), '/discussion', {'/': {'request.dispatch': cherrypy.dispatch.MethodDispatcher()}}
|
||||
)
|
||||
|
||||
# Method-Dispatcher für die "Applikation" "discussion" vereinbaren
|
||||
cherrypy.tree.mount(
|
||||
post.Post_cl(), '/post', {'/': {'request.dispatch': cherrypy.dispatch.MethodDispatcher()}}
|
||||
)
|
||||
|
||||
# Method-Dispatcher für die "Applikation" "login" vereinbaren
|
||||
cherrypy.tree.mount(
|
||||
login.Login_cl(), '/login', {'/': {'request.dispatch': cherrypy.dispatch.MethodDispatcher()}}
|
||||
)
|
||||
|
||||
# Method-Dispatcher für die "Applikation" "template" vereinbaren
|
||||
cherrypy.tree.mount(
|
||||
template.Template_cl(), '/template', {'/': {'request.dispatch': cherrypy.dispatch.MethodDispatcher()}}
|
||||
)
|
||||
|
||||
cherrypy.engine.start()
|
||||
cherrypy.engine.block()
|
||||
|
||||
#----------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
#----------------------------------------------------------
|
||||
main()
|
Reference in New Issue
Block a user