Ejemplo n.º 1
0
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',
            'tools.staticdir.index': 'index.html'
        }
    }
    # Mount static content handler
    root_o = cherrypy.tree.mount(application.Application(current_dir), '/', static_config)
    # suppress traceback-info
    cherrypy.config.update({'request.show_tracebacks': False})
    # Start server
    cherrypy.engine.start()
    cherrypy.engine.block()
 def main(self):
     # 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
     cherrypy.engine.autoreload.unsubscribe()
     # activate logger
     cherrypy.config.update({
         'log.access_file': "access.log",
         'log.error_file': "server.log",
         'log.screen': True,
     })
     # Static content config
     static_config = {
         '/': {
             'tools.staticdir.root': current_dir,
             'tools.staticdir.on': True,
             'tools.staticdir.dir': './content'
         }
     }
     # Mount static content handler
     cherrypy.tree.mount(application.Application(), '/', static_config)
     cherrypy.tree.mount(self, '/shutdown', {'/': {}})
     # suppress traceback-info
     cherrypy.config.update({'request.show_tracebacks': False})
     # Start server
     cherrypy.engine.start()
     cherrypy.engine.block()
Ejemplo n.º 3
0
def main():
    settings = config.server
    settings["static_path"] = config.static_path
    settings["template_path"] = config.template_path
    port = settings.pop("port")
    address = settings.pop("host")
    sockets = bind_sockets(port, address=address)

    if sys.platform != "win32":
        import uvloop

        asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

    fork_processes(0 if config.env != "dev" else 1)

    AsyncIOMainLoop().install()
    loop = asyncio.get_event_loop()
    ThreadPool.init_thread_pool(workers=config.server["thread_worker"])

    app = application.Application(
        settings=settings,
        loop=loop,
        model_routers=MODEL_ROUTERS,
        before_hooks=BEFORE_HOOKS,
        after_hooks=AFTER_HOOKS,
        delay_tasks=DELAY_TASKS,
        periodic_tasks=PERIODIC_TASKS,
    )

    app.start_periodic_tasks()
    app.start_delay_tasks()
    server = httpserver.HTTPServer(app)
    server.add_sockets(sockets)
    logging.debug(f"🚀 Server ready at http://{address}:{port}")
    loop.run_forever()
Ejemplo n.º 4
0
def main():
    reload(sys)
    sys.setdefaultencoding('utf8')

    logging.config.dictConfig(yaml.load(open("logging.yaml", 'r')))

    conf = ConfigParser.ConfigParser()
    conf.read(config_file_path)
    http_port = conf.getint("http", "port")

    app = application.Application([
        (r"/crossdomain.xml", CrossdomainHandle),
        (r"/10001", login_handler.LoginHandle),
        (r"/10002", bind_handler.BindHandle),
        (r"/10003", change_handler.ChangeHandle),
        (r"/10004", map_handler.ViewMapHandler),
        (r"/10005", comment_handler.ViewCommentHandler),
        (r"/10006", play_handler.PlayHandler),
        (r"/10007", complete_handler.CompleteHandler),
        (r"/10008", search_handler.SearchMapHandler),
        (r"/10009", favourite_handler.FavouriteMapHandler),
        (r"/10010", play_handler.RePlayHandler),
        (r"/10011", view_handler.ViewAllHandler),
        (r"/10012", create_handler.CreateMapHandler),
        (r"/10013", edit_handler.EditHandler),
        (r"/10014", save_handler.SaveHandler),
        (r"/10015", name_handler.ChangeNameHandler),
        (r"/10016", upload_handler.UploadHandler),
        (r"/10017", delete_handler.DeleteMapHandler),
        (r"/10018", comment_handler.CommentHandler),
        (r"/10019", rank_handler.ViewRankHandler),
        (r"/10020", video_handler.ViewVideoHandler),
        (r"/10021", view_handler.ViewSingleHandler),
        (r"/10022", shop_handler.ShopBuyHandler),
        (r"/10023", player_handler.ViewPlayerHandler),
        (r"/10024", guide_handler.GuideHandler),
        (r"/10031", login_platform_handler.LoginPlatformHandler),
        (r"/10032", change_name_handler.ChangeNameHandler),
        (r"/10033", pay_handler.PayHandler),
        (r"/10034", libao_handler.LibaoHandler),
        (r"/10035", challenge_view_handler.ViewHandler),
        (r"/10036", challenge_start_handler.StartHandler),
        (r"/10037", challenge_start_handler.StartHandler),
        (r"/10038", challenge_replay_handler.RePlayHandler),
        (r"/10039", challenge_fail_handler.FailHandler),
        (r"/10040", challenge_success_handler.SuccessHandler),
        (r"/10041", challenge_rank_handler.RankHandler),
        (r"/10042", challenge_buy_handler.BuyHandler),
        (r"/10043", google_pay_handler.GooglePayHandler),
        (r"/10044", like_handler.MapLikeHandler),
        (r"/10045", download_handler.DownloadHandler),
    ], conf)

    http_server = tornado.httpserver.HTTPServer(app)
    http_server.listen(http_port)
    tornado.ioloop.IOLoop.instance().start()
Ejemplo n.º 5
0
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': 8081,
        '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(), '/', 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()
Ejemplo n.º 6
0
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.current_dir = current_dir

    # disable autoreload
    cherrypy.engine.autoreload.unsubscribe()

    # activate logger
    cherrypy.config.update({
        'log.access_file': "access.log",
        'log.error_file': "server.log",
        'log.screen': True,
    })
    # suppress traceback-info
    cherrypy.config.update({'request.show_tracebacks': False})
    config_file_name = os.path.join(current_dir, 'server.conf')
    if os.path.exists(config_file_name) == False:
        config_file_name = None  # Datei gibt es nicht

    # 1. Eintrag: Standardverhalten, Berücksichtigung der Konfigurationsangaben im server.conf
    cherrypy.tree.mount(None, '/', config_file_name)

    # 2. Eintrag: Method-Dispatcher für die "Applikation" "app" vereinbaren
    cherrypy.tree.mount(
        application.Application(), '/app', {
            '/': {
                'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
                'tools.response_headers.on': True,
                'tools.response_headers.headers':
                [('Content-Type', 'text/plain')]
            }
        })

    # 3. Eintrag: Method-Dispatcher für die "Applikation" "templates" vereinbaren
    cherrypy.tree.mount(
        template.Template(), '/templates', {
            '/': {
                'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
                'tools.response_headers.on': True,
                'tools.response_headers.headers':
                [('Content-Type', 'text/plain')]
            }
        })

    # Start server
    cherrypy.engine.start()
    cherrypy.engine.block()
Ejemplo n.º 7
0
    line interface arguments to the Application

    @param None
    """
    arguments = args.ApplicationCLI()
    """Instantiate the Application

    Setup the basic Application class in order to instantiate the rest of
    the Application

    @param (str) name
        The name of the Application
    @param (str) envioronment
        The desired environment configuration to start the application on
    """
    instance = application.Application(name=__name__,
                                       environment=arguments.args.environment)
    """Run the application.

    Run the application with the given variables

    @param (str) host
        The hostname to listen on
    @param (int) port
        The port of the webserver
    @param (bool) debug
        Enable or disable debug mode
    @param (dict) **options
        Options to be forwarded to the underlying Werkzeug server

    @see http://werkzeug.pocoo.org/docs/0.11/serving/\
            #werkzeug.serving.run_simple
Ejemplo n.º 8
0
from app import application

if __name__ == '__main__':
    my_app = application.Application()
    my_app.run()