aiohttp模块的web.Application()方法是搭建WebApp的核心
async def init(loop):
await www.orm.create_pool(loop=loop, host='127.0.0.1', port=3306, user='root', password='password', db='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
可以看出,
app = web.Application(loop=loop, middlewares=[
logger_factory, response_factory
])
一、接受的参数
Parameters: |
|
---|