34 lines
736 B
Python
Executable File
34 lines
736 B
Python
Executable File
#! /usr/bin/env python3
|
|
|
|
from pos.config import Config
|
|
from pos.logging import init_logging, get_logger
|
|
from pos.database import Database
|
|
from pos.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'))
|
|
|