def main(): try: current_dir = os.path.dirname(os.path.abspath(__file__)) except: current_dir = os.path.dirname(os.path.abspath(sys.executable)) 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() } } normalConfig_o = { '/': { 'tools.staticdir.root': current_dir, 'request.dispatch': cherrypy.dispatch.MethodDispatcher() } } cherrypy.tree.mount(None, '/', staticConfig_o) app_o = application.Application_cl(current_dir) cherrypy.tree.mount(app_o.claim, '/claim', normalConfig_o) cherrypy.engine.start() cherrypy.engine.block()
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 static_config = { '/': { 'tools.staticdir.root': current_dir, 'tools.staticdir.on': True, 'tools.staticdir.dir': './content' } } # Mount static content handler root_o = cherrypy.tree.mount(application.Application_cl(), '/', static_config) # suppress traceback-info cherrypy.config.update({'request.show_tracebacks': False}) # Start server cherrypy.engine.start() cherrypy.engine.block()
def main(): # Get current directory currDir_s = sys.path[0] # Configuration for the API API_CONf = { '/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), 'tools.sessions.on': True, 'tools.response_headers.on': True, 'tools.response_headers.headers': [('Content-Type', 'text/plain')] } } # Configuration for the static mainpage CONF = { '/': { 'tools.staticdir.root': currDir_s, 'tools.staticdir.on': True, 'tools.staticdir.dir': './content', 'tools.staticdir.index': '../templates/index.html' } } cherrypy.tree.mount(None, '/', CONF) cherrypy.tree.mount(application.Application_cl(currDir_s), '/api', API_CONf) cherrypy.engine.start() cherrypy.engine.block()
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) # Start server cherrypy.engine.start() cherrypy.engine.block()
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 = os.path.join(currentDir_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() # 1. Eintrag: Standardverhalten, Berücksichtigung der Konfigurationsangaben im configFile cherrypy.tree.mount(None, '/', configFileName_s) # 2. Eintrag: Method-Dispatcher für die "Applikation" "app" vereinbaren cherrypy.tree.mount( application.Application_cl(), '/app', {'/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher() }}) # 2. Eintrag: Method-Dispatcher für die "Applikation" "templates" vereinbaren cherrypy.tree.mount( template.Template_cl(), '/templates', {'/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher() }}) cherrypy.engine.start() cherrypy.engine.block()
def main(): #-------------------------------------- currDir_s = sys.path[0] # disable autoreload cherrypy.engine.autoreload.unsubscribe() # Static content config static_config = { '/': { 'tools.staticdir.root': currDir_s, 'tools.staticdir.on': True, 'tools.staticdir.dir': './content' } } # Mount static content handler cherrypy.tree.mount(application.Application_cl(currDir_s), '/', static_config) # suppress traceback-info cherrypy.config.update({'request.show_tracebacks': False}) # Start server cherrypy.engine.start() cherrypy.engine.block()
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() cherrypy.quickstart(application.Application_cl(), config=configFileName_s)
# im aktuellen Verzeichnis configFileName_s = os.path.join(currentDir_s, 'server.conf') if not os.path.exists(configFileName_s): # Datei gibt es nicht configFileName_s = None # autoreload-Monitor hier abschalten # cherrypy.engine.autoreload.unsubscribe() # 1. Eintrag: Standardverhalten, Berücksichtigung der Konfigurationsangaben im configFile cherrypy.tree.mount(None, '/', configFileName_s) # 2. Eintrag: Method-Dispatcher für die "Applikation" "app" vereinbaren cherrypy.tree.mount( application.Application_cl(), '/app', {'/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher() }}) # 3. Eintrag: Method-Dispatcher für die "Applikation" "templates" vereinbaren cherrypy.tree.mount( template.Template_cl(), '/templates', {'/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher() }}) # 4. Eintrag: Method-Dispatcher für die "Applikation" "projekt" vereinbaren cherrypy.tree.mount( project.Project_cl(currentDir_s), '/projekt', {'/': {
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)) cherrypy.Application.currentDir = current_dir # disable autoreload and timeout_monitor cherrypy.engine.autoreload.unsubscribe() cherrypy.engine.timeout_monitor.unsubscribe() cherrypy.tree.mount(application.Application_cl(), '/', {"/": {}}) css_handler = cherrypy.tools.staticdir.handler(section="/", dir='/content/css') cherrypy.tree.mount( css_handler, '/css', { '/': { 'tools.staticdir.root': current_dir, 'tools.staticdir.on': True, 'tools.staticdir.dir': 'content/css' } }) js_handler = cherrypy.tools.staticdir.handler(section="/", dir='/content/js') cherrypy.tree.mount( js_handler, '/js', { '/': { 'tools.staticdir.root': current_dir, 'tools.staticdir.on': True, 'tools.staticdir.dir': 'content/js' } }) cherrypy.tree.mount(studierender.Studierender_cl(), '/studierender', {"/": {}}) cherrypy.tree.mount(mhpflege.MhPflege_cl(), '/mhpflege', {"/": {}}) cherrypy.tree.mount( studiengang.Studiengang_cl(), '/studiengang', {'/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher() }}) cherrypy.tree.mount( modulhandbuch.Modulhandbuch_cl(), '/modulhandbuch', {'/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher() }}) cherrypy.tree.mount( lehrveranstaltung.Lehrveranstaltung_cl(), '/lehrveranstaltung', {'/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher() }}) cherrypy.tree.mount( modul.Modul_cl(), '/modul', {'/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher() }}) cherrypy.tree.mount( login.Login_cl(), '/login', {'/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher() }}) cherrypy.tree.mount( template.Template_cl(), '/template', {'/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher() }}) cherrypy.Application.db = database.Database_cl() cherrypy.Application.user = user.User_cl() # Start server cherrypy.engine.start() cherrypy.engine.block()
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)) cherrypy.Application.currentDir = current_dir # disable autoreload and timeout_monitor cherrypy.engine.autoreload.unsubscribe() cherrypy.engine.timeout_monitor.unsubscribe() cherrypy.tree.mount(application.Application_cl(), '/', {"/": {}}) css_handler = cherrypy.tools.staticdir.handler(section="/", dir='/content/css') cherrypy.tree.mount( css_handler, '/css', { '/': { 'tools.staticdir.root': current_dir, 'tools.staticdir.on': True, 'tools.staticdir.dir': 'content/css' } }) js_handler = cherrypy.tools.staticdir.handler(section="/", dir='/content/js') cherrypy.tree.mount( js_handler, '/js', { '/': { 'tools.staticdir.root': current_dir, 'tools.staticdir.on': True, 'tools.staticdir.dir': 'content/js' } }) cherrypy.tree.mount(diskussionen.Diskussionen_cl(), '/diskussionen', {'/': { 'tools.staticdir.root': current_dir }}) cherrypy.tree.mount(themen.Themen_cl(), '/themen', {'/': { 'tools.staticdir.root': current_dir }}) cherrypy.tree.mount(beitraege.Beitraege_cl(), '/beitraege', {'/': { 'tools.staticdir.root': current_dir }}) cherrypy.tree.mount(login.Login_cl(), '/login', {'/': { 'tools.staticdir.root': current_dir }}) cherrypy.tree.mount(benutzer.Benutzer_cl(), '/benutzer', {'/': { 'tools.staticdir.root': current_dir }}) cherrypy.tree.mount( beitraege_api.Beitraege(), '/api/beitraege', { '/': { 'tools.staticdir.root': current_dir, 'request.dispatch': cherrypy.dispatch.MethodDispatcher() } }) cherrypy.tree.mount( benutzer_api.Benutzer(), '/api/benutzer', { '/': { 'tools.staticdir.root': current_dir, 'request.dispatch': cherrypy.dispatch.MethodDispatcher() } }) cherrypy.tree.mount( themen_api.Themen(), '/api/themen', { '/': { 'tools.staticdir.root': current_dir, 'request.dispatch': cherrypy.dispatch.MethodDispatcher() } }) cherrypy.tree.mount( diskussionen_api.Diskussionen(), '/api/diskussionen', { '/': { 'tools.staticdir.root': current_dir, 'request.dispatch': cherrypy.dispatch.MethodDispatcher() } }) cherrypy.Application.db = database.Database_cl() cherrypy.Application.user = user.User_cl() cherrypy.Application.view = view.View_cl() # Start server cherrypy.engine.start() cherrypy.engine.block()