autogestionale/web.py

33 lines
779 B
Python
Raw Normal View History

2017-09-30 01:36:10 +02:00
#! /usr/bin/env python3
2017-09-30 02:45:43 +02:00
from autogestionale.config import Config
from autogestionale.logging import init_logging, get_logger
from autogestionale.database import Database
from autogestionale.routes import setup_routes
2017-09-30 01:36:10 +02:00
import asyncio
from aiohttp import web
log = get_logger('web')
def setup_app(loop, config):
app = web.Application(loop=loop)
app['config'] = config
setup_routes(app)
return app
if __name__ == '__main__':
config = Config()
init_logging(config.logging)
conf_db = config.core['DATABASE']
db = Database(**conf_db)
loop = asyncio.get_event_loop()
app = setup_app(loop, config)
web.run_app(app,
host=config.core.get('GENERAL', 'Address'),
port=config.core.getint('GENERAL', 'Port'))