Ejemplo n.º 1
0
def init(loop):
    yield from orm.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, 'handlers')
    add_static(app)
    srv = yield from loop.create_server(app.make_handler(), '127.0.0.1', 8050)
    logging.info('server started at http://127.0.0.1:8050...')
    return srv
Ejemplo n.º 2
0
def init(loop):
    # 创建数据库连接池,db参数传配置文件里边的db
    yield from orm.create_pool(loop=loop, **configs.db)
    # middlewares 设置两个中间处理函数
    # middlewares 中的每个factory接收两个参数,app和handler,即middlewares中下一个handler
    # middlewares 的最后一个元素的 handler会通过routes查找到相应的 routes注册的handler
    app = web.Application(loop=loop, middlewares=[logger_factory, auth_factory, response_factory])
    # 初始化 jinja2模板
    init_jinja2(app, filters=dict(datetime=datetime_filter))
    # 添加请求的 handlers,即各个请求相对应的处理函数
    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.º 3
0
def test(loop):
    yield from orm.create_pool(loop=loop, user='www-data', password='www-data', database='awesome')
    u=User(admin=True, name='kHRYSTAL', email='[email protected]', passwd=hashlib.sha1(('%s:%s' % (next_id(), 'yyg1990918')).encode('utf-8')).hexdigest(), image='about:blank')
    yield from u.save()
Ejemplo n.º 4
0
def test():
    yield from orm.create_pool(user='xl', password='xulei123', database='awesome')
    u = user(name='test', email='[email protected]', passwd='test', image='about:blank')
    yield from u.save()
Ejemplo n.º 5
0
def test(loop):
    yield from orm.create_pool(loop=loop, user='www-data', password='www-data', database='awesome')
    u=User(name='Yao', email='[email protected]', passwd="sas", image='about:blank')
    yield from u.save()
Ejemplo n.º 6
0
def test(loop, x):
    yield from orm.create_pool(user='root', password='', database='awesome', loop=loop)

    u = User(name='Test%d' % x, email='test%[email protected]' % x, passwd='123456', image='about:blank')

    yield from u.save()
Ejemplo n.º 7
0
def test(loop):
    yield from orm.create_pool(loop, user='rjh', password='rang123', database='awesome_study')
    u = User(name='Test', email='[email protected]', passwd='1234567890', image='about:blank')
    yield from u.save()