def init(loop):
# load config from yaml file
conf = load_config(str(PROJ_ROOT / 'config' / 'dev.yml'))
# setup application and extensions
app = web.Application(loop=loop)
pg = await setup_pg(app, conf, loop)
# init modules
aiohttp_jinja2.setup(
app, loader=jinja2.FileSystemLoader(str(TEMPLATES_ROOT)))
admin = setup_admin(app, pg)
app.router.add_subapp('/admin/', admin)
# setup views and routes
handler = SiteHandler(pg)
add_route = app.router.add_route
add_route('GET', '/', handler.index)
app.router.add_static('/static', path=str(PROJ_ROOT / 'static'))
host, port = conf['host'], conf['port']
return app, host, port
评论列表
文章目录