Beispiel #1
0
    async def init(loop):
        my_web_app = web.Application(loop=loop)
        main_router(my_web_app)

        srv = await loop.create_server(my_web_app.make_handler(),
                                       ip, port)

        print("Server started at port {}".format(port))
        return srv
Beispiel #2
0
from conf import settings
from urls import main_router

# Run server

if settings.RUNNING_ALONE:
    ip = settings.DEBUG_IP
    port = settings.DEBUG_PORT

    async def init(loop):
        my_web_app = web.Application(loop=loop)
        main_router(my_web_app)

        srv = await loop.create_server(my_web_app.make_handler(),
                                       ip, port)

        print("Server started at port {}".format(port))
        return srv

    loop = asyncio.get_event_loop()
    loop.run_until_complete(init(loop))
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        sys.exit()
    finally:
        loop.close()
else:
    my_web_app = web.Application()
    main_router(my_web_app)