-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry.py
executable file
·38 lines (33 loc) · 1.17 KB
/
entry.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
34
35
36
37
38
#!/bin/python3
from argparse import ArgumentParser
from hypercorn.config import Config as hypercornConfig
from hypercorn.middleware import AsyncioWSGIMiddleware
from hypercorn.asyncio import serve
from asyncio import run
from platform import uname
from remotelauncher import app
parser = ArgumentParser(
prog=app.config['APPNAME'],
description='Config and run programs from the web!'
)
parser.add_argument(
'--debug',
nargs='?',
default='production',
choices=['hypercorn', 'flask'],
help='enable debug mode'
)
args = parser.parse_args()
hypercornconfig = hypercornConfig()
match uname().system:
case 'Linux':
hypercornconfig.bind = ["[::]:2023"]
case _:
hypercornconfig.bind = ["[::]:2023", "0.0.0.0:2023"]
if args.debug == 'flask':
app.run(host='::', port=2023, debug=True)
elif args.debug == 'hypercorn' or args.debug == None:
hypercornconfig.accesslog = '-'
run(serve(AsyncioWSGIMiddleware(app, max_body_size=app.config['MAX_CONTENT_LENGTH']), hypercornconfig, mode='asgi'), debug=True)
else:
run(serve(AsyncioWSGIMiddleware(app, max_body_size=app.config['MAX_CONTENT_LENGTH']), hypercornconfig, mode='asgi'), debug=False)