-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
39 lines (33 loc) · 1.01 KB
/
main.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
39
import os
Import_Error = ImportError
path = os.path.abspath(__file__)
dir_path = os.path.dirname(path)
os.chdir(dir_path)
import waitress # noqa: E402
from rich import pretty, traceback # noqa: E402
from rich.console import Console # noqa: E402
from rich.panel import Panel # noqa: E402
pretty.install()
traceback.install(show_locals=False)
from about import project, title, version # noqa: E402
from api import api # noqa: E402
from reader.arg import ArgReader # noqa: E402
from utils.log import Log # noqa: E402
db = ArgReader.read()
if db.version is not None:
print(db.version)
else:
ident = f"{project} - {title} v:{version}"
console = Console()
console.print(Panel.fit(ident))
Log.init(config=db.log_config)
api_instance = api(title=title, version=version)
Log.get("api").success(f"Accept requests at {db.host}:{db.port}")
waitress.serve(
api_instance,
host=db.host,
port=db.port,
expose_tracebacks=False,
ident=ident,
_quiet=True,
)