Ejemplo n.º 1
0
def init(loop):
    yield from create_pool(loop=loop, **configs.db)
    app = web.Application(
        loop=loop,
        middlewares=[logger_factory, auth_factory, response_factory])
    init_jinja2(app, filters=dict(datetime=datetime_filter))
    add_routes(app, 'controller')
    add_static(app)
    srv = yield from loop.create_server(app.make_handler(), '127.0.0.1', 9000)
    logging.info('server started at http://127.0.0.1:9000...')
    return srv
Ejemplo n.º 2
0
async def init(loop):
    await orm.create_pool(loop=loop, host='127.0.0.1', port=3306, user='******', password='', database='awesome')
    app = web.Application(loop=loop, middlewares=[
        logger_factory, response_factory
    ])
    init_jinja2(app, filters=dict(datetime=datetime_filter))
    add_routes(app, 'handlers')
    add_static(app)
    srv = await loop.create_server(app.make_handler(), '127.0.0.1', 9000)
    logging.info('server started at http://127.0.0.1:9000...')
    return srv
Ejemplo n.º 3
0
async def init(loop):
    await www.orm.create_pool(loop=loop, **configs.db)
    ## 在handles.py 完成后 ,在下面的middlewares的list中加入auto_factory
    app = web.Application(loop=loop,
                          middlewares=[logger_factory, response_factory])
    init_jinja2(app, filters=dict(datetime=datetime_filter))
    add_routes(app, 'handlers')
    add_static(app)
    srv = await loop.create_server(app._make_handler(), '127.0.0.1', 9000)
    logging.info('server started at http://127.0.0.1:9000')
    return srv
Ejemplo n.º 4
0
def init(loop):
    yield from www.orm.create_pool(loop=loop, host='127.0.0.1', port=3306, user='******', password='******', db='microblog')
    # 创建一个web服务器对象
    app = web.Application(loop=loop, middlewares=[
        logger_factory, response_factory
    ])
    init_jinja2(app, filters=dict(datetime=datetime_filter))
    add_routes(app, 'handlers')
    add_static(app)
    srv = yield from loop.create_server(app.make_handler(), '127.0.0.1', 9000)
    logging.info('server started at http://127.0.0.1:9000...')
    return srv
Ejemplo n.º 5
0
async def init(loop):
    await create_connection_pool(loop=loop, **configs.db)

    from www.middleware import logger_factory, data_factory, auth_factory, response_factory
    app = web.Application(loop=loop, middlewares=[
        logger_factory, auth_factory, data_factory, response_factory
    ])
    init_jinja2(app=app, filters=dict(datetime=datetime_filter))
    add_static(app=app)
    add_routes(app=app, module_name='www.handlers')
    server = await loop.create_server(app.make_handler(), host='127.0.0.1', port=8080)
    logging.info('server started at http://127.0.0.1:8080')
    return server
Ejemplo n.º 6
0
def init(loop):
    # yield from init_mysql()
    # yield from create_pool(loop, **blog_configs['db'])
    app = aiohttp.web.Application(
        loop=loop,
        middlewares=[logger_factory, auth_factory, response_factory])
    init_jinja2(app, filters=dict(datetime=datetime_filter))
    add_routes(app, 'handlers')
    add_static(app)

    # app.router.add_route('GET', '/', index)
    server = yield from loop.create_server(app.make_handler(), '127.0.0.1',
                                           9000)
    logging.info('server started at 127.0.0.1:9000')
    return server
Ejemplo n.º 7
0
async def init(loop):
    await orm.create_pool(loop=loop,
                          user=configs.db.user,
                          password=configs.db.password,
                          db=configs.db.database)
    app = web.Application(
        loop=loop,
        middlewares=[logger_factory, auth_factory, response_factory])

    init_jinja2(app, filters=dict(datetime=datetime_filter))
    add_routes(app, 'handlers')
    add_static(app)
    srv = await loop.create_server(app.make_handler(), '127.0.0.1', 9000)
    logging.info('server started at http://127.0.0.1:9000...')
    return srv
Ejemplo n.º 8
0
async def init(loop):
    await www.orm.create_pool(loop=loop,
                              host='127.0.0.1',
                              port=3306,
                              user='******',
                              password='******',
                              db='awesome')
    app = web.Application(
        loop=loop,
        middlewares=[logger_factory, auth_factory, response_factory])
    init_jinja2(app, filters=dict(datetime=datetime_filter))
    add_routes(app, 'handlers')
    add_static(app)
    srv = await loop.create_server(app.make_handler(), '127.0.0.1', 9000)
    logging.info('server started at http://127.0.0.1:9000...')
    return srv
Ejemplo n.º 9
0
async def init(loop):
    await orm.create_pool(loop=loop,
                          host=configs.db.host,
                          port=configs.db.port,
                          user=configs.db.user,
                          password=configs.db.password,
                          db=configs.db.db)
    app = web.Application(
        loop=loop,
        middlewares=[logger_factory, data_factory, response_factory])
    init_jinja2(app, filters=dict(datetime=datetime_filter))
    add_routes(app, *configs.web.handlers)
    add_static(app)
    runner = web.AppRunner(app)
    await runner.setup()
    port = 9000 if not configs.web.port else configs.web.port
    site = web.TCPSite(runner, '127.0.0.1', port)
    logging.info('server started at http://127.0.0.1:%s...' % port)
    await site.start()