autogestionale/web.py

33 lines
779 B
Python
Executable File

#! /usr/bin/env python3
from autogestionale.config import Config
from autogestionale.logging import init_logging, get_logger
from autogestionale.database import Database
from autogestionale.routes import setup_routes
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'))