Update: Logic with Twitch login now works.

This commit is contained in:
2025-11-17 02:10:00 +01:00
parent 8829228295
commit 0967983483
2 changed files with 15 additions and 6 deletions

15
main.py
View File

@@ -3,6 +3,7 @@ from fastapi import FastAPI, Request
from starlette.middleware.sessions import SessionMiddleware
from starlette.staticfiles import StaticFiles
from starlette.responses import FileResponse, RedirectResponse
from contextlib import asynccontextmanager
import models
from database import engine
@@ -14,12 +15,16 @@ from config import settings # Import settings to get the secret key
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_DIR = os.path.join(BASE_DIR, "static")
# This line tells SQLAlchemy to create all the tables based on the models
# we defined. It will create the `multichat_overlay.db` file with the
# 'users' and 'settings' tables if they don't exist.
models.Base.metadata.create_all(bind=engine)
@asynccontextmanager
async def lifespan(app: FastAPI):
# This code runs on startup
print("Application startup: Creating database tables...")
models.Base.metadata.create_all(bind=engine)
print("Application startup: Database tables created.")
yield
# Code below yield runs on shutdown, if needed
app = FastAPI()
app = FastAPI(lifespan=lifespan)
# Mount the 'static' directory using an absolute path for reliability
app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")