-
Notifications
You must be signed in to change notification settings - Fork 7
/
server.py
30 lines (26 loc) · 1.02 KB
/
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
import sys
import uuid
import typing as t
import pwd
import os
import werkzeug.debug
from werkzeug.serving import run_simple
from app import app
import multiprocessing
def initialize():
if os.environ.get("WERKZEUG_RUN_MAIN") == "true":
user = pwd.getpwuid(os.getuid())[0]
modname = getattr(app, "__module__", t.cast(object, app).__class__.__module__)
mod = sys.modules.get(modname)
app_name = getattr(app, "__name__", type(app).__name__)
mod_file_loc = getattr(mod, '__file__', None)
mac_addr = str (uuid.getnode ())
machine_id = werkzeug.debug.get_machine_id()
print("User: %s\nModule: %s\nModule Name: %s\nApp Location: %s\nMac Address: %s\nWerkzeug Machine ID: %s\n"
% (user, modname, app_name, mod_file_loc, mac_addr, machine_id))
def start_server():
run_simple('0.0.0.0', 7777, app, use_reloader=True, use_debugger=True, use_evalex=True)
if __name__ == '__main__':
proc = multiprocessing.Process(target=start_server)
proc.start()
initialize()