macao-pos/web.py

34 lines
723 B
Python
Raw Permalink Normal View History

#!/usr/bin/env python3
import asyncio
from aiohttp import web
2017-03-21 11:26:25 +01:00
from pos.config import Config
from pos.logging import setup_logging, get_logger
from pos.database import Database
from pos.routes import setup_routes
2017-03-21 11:26:25 +01:00
log = get_logger('web')
def setup_app(loop, config):
app = web.Application(loop=loop)
2017-03-21 11:26:25 +01:00
app['config'] = config
app['db'] = Database(**config.core['DATABASE'])
2017-03-21 11:26:25 +01:00
setup_routes(app)
2017-03-21 11:26:25 +01:00
return app
2017-03-21 11:26:25 +01:00
if __name__ == '__main__':
config = Config()
setup_logging(config.logging)
2017-03-21 11:26:25 +01:00
loop = asyncio.get_event_loop()
2017-03-21 11:26:25 +01:00
app = setup_app(loop, config)
web.run_app(app,
host=config.core.get('GENERAL', 'Address'),
port=config.core.getint('GENERAL', 'Port'))