2018-08-10 19:19:38 +00:00
|
|
|
import asyncio
|
|
|
|
import aiohttp.web
|
|
|
|
import logging
|
|
|
|
|
2018-10-30 22:35:04 +00:00
|
|
|
from . import app, CONFIG
|
2018-08-10 19:19:38 +00:00
|
|
|
|
|
|
|
async def start_webserver():
|
|
|
|
runner = aiohttp.web.AppRunner(app)
|
|
|
|
await runner.setup()
|
2018-10-30 22:35:04 +00:00
|
|
|
try:
|
|
|
|
listen = CONFIG['listen']
|
|
|
|
except:
|
|
|
|
listen = 'localhost'
|
|
|
|
try:
|
|
|
|
port = CONFIG['port']
|
|
|
|
except:
|
|
|
|
port = 8080
|
|
|
|
|
|
|
|
logging.info('Starting webserver at {listen}:{port}'.format(listen=listen,port=port))
|
|
|
|
|
|
|
|
site = aiohttp.web.TCPSite(runner, listen, port)
|
2018-08-10 19:19:38 +00:00
|
|
|
await site.start()
|
|
|
|
|
|
|
|
def main():
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
asyncio.ensure_future(start_webserver())
|
|
|
|
loop.run_forever()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|