44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
import os
|
|
import schedule
|
|
from dotenv import load_dotenv
|
|
from nicegui import ui, app
|
|
from gui import setup_all_routes
|
|
|
|
from utils import season_scheduler
|
|
from starlette.requests import Request
|
|
from wood import logger
|
|
|
|
# 1. Load the secret variables from the .env file into memory
|
|
load_dotenv()
|
|
|
|
# Fixed directory for the pictures (must remain here!)
|
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
PICTURE_DIR = os.path.join(BASE_DIR, "gui", "pictures")
|
|
|
|
# Fixed path for the web server
|
|
app.add_static_files('/pictures', PICTURE_DIR)
|
|
|
|
# 2. Retrieve variables
|
|
client_id = os.getenv("DISCORD_CLIENT_ID")
|
|
client_secret = os.getenv("DISCORD_CLIENT_SECRET")
|
|
admin_discord_id = os.getenv("ADMIN")
|
|
url = os.getenv("APP_URL")
|
|
|
|
|
|
logger.setup_log_db()
|
|
|
|
# 3. Build page routes
|
|
setup_all_routes()
|
|
|
|
# Timer of schedule regularly checks
|
|
@app.on_startup
|
|
def setup_scheduler():
|
|
import threading
|
|
from utils.season_scheduler import run_scheduler
|
|
|
|
thread = threading.Thread(target=run_scheduler, daemon=True)
|
|
thread.start()
|
|
|
|
# 4. Start the App Runtime on the server.
|
|
ui.run(title="Westside Diceghost Liga", port=9000, storage_secret="EIN_super-geheimes_Pa$$wort#!", favicon="gui/pictures/wsdg.png")
|