forked from merfrei/proxy-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
33 lines (24 loc) · 764 Bytes
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
This is the main AIOHTTP server for the Proxy Service API
"""
import asyncio
import argparse
from aiohttp import web
from config import get_config
from api import init_app
DESCRIPTION = 'Proxy Service API: aiohttp server'
def parse_arguments():
'''Parse the command line arguments'''
parser = argparse.ArgumentParser(description=DESCRIPTION)
parser.add_argument('--path')
parser.add_argument('--port')
return parser.parse_args()
def run_server():
'''Run the main aiohttp server'''
config = get_config()
loop = asyncio.get_event_loop()
app = loop.run_until_complete(init_app(loop, config))
args = parse_arguments()
web.run_app(app, path=args.path, port=args.port)
if __name__ == '__main__':
run_server()