mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 04:01:32 -06:00
Database-backed Webhosting
This commit is contained in:
31
WebHost.py
Normal file
31
WebHost.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import os
|
||||
import multiprocessing
|
||||
import logging
|
||||
|
||||
from WebHost import app
|
||||
from waitress import serve
|
||||
|
||||
from WebHost.models import db
|
||||
|
||||
DEBUG = False
|
||||
|
||||
if __name__ == "__main__":
|
||||
multiprocessing.freeze_support()
|
||||
multiprocessing.set_start_method('spawn')
|
||||
logging.basicConfig(format='[%(asctime)s] %(message)s', level=logging.INFO)
|
||||
|
||||
configpath = "config.yaml"
|
||||
|
||||
if os.path.exists(configpath):
|
||||
import yaml
|
||||
|
||||
with open(configpath) as c:
|
||||
app.config.update(yaml.safe_load(c))
|
||||
|
||||
logging.info(f"Updated config from {configpath}")
|
||||
db.bind(**app.config["PONY"])
|
||||
db.generate_mapping(create_tables=True)
|
||||
if DEBUG:
|
||||
app.run(debug=True)
|
||||
else:
|
||||
serve(app, port=80, threads=1)
|
Reference in New Issue
Block a user