design final
This commit is contained in:
parent
a0d2188f6f
commit
99a690972e
1414 changed files with 2389 additions and 1455 deletions
37
main.py
37
main.py
|
|
@ -1,5 +1,7 @@
|
|||
import os
|
||||
import shutil
|
||||
import csv
|
||||
from pathlib import Path
|
||||
from fastapi import FastAPI, UploadFile, File, Request, Form
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
|
@ -11,6 +13,15 @@ from mailer import send_order_sync
|
|||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
# Get server hostname from environment
|
||||
SERVER_HOSTNAME = os.environ.get("SERVER_HOSTNAME", "einszwovier.local")
|
||||
BOOKSTACK_PORT = os.environ.get("BOOKSTACK_PORT", "6875")
|
||||
OPENWEBUI_PORT = os.environ.get("OPENWEBUI_PORT", "8080")
|
||||
PORTAINER_PORT = os.environ.get("PORTAINER_PORT", "9000")
|
||||
|
||||
# Courses CSV path
|
||||
COURSES_CSV = Path("data/courses.csv")
|
||||
|
||||
app = FastAPI()
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
|
||||
|
|
@ -68,13 +79,30 @@ async def welcome(request: Request):
|
|||
{
|
||||
"request": request,
|
||||
"studio_open": presence_state["present"],
|
||||
"opening_hours": "Di-Do 11:00–16:00", # or read from config
|
||||
"opening_hours": "Di-Do 11:00–16:00",
|
||||
"server_hostname": SERVER_HOSTNAME,
|
||||
"bookstack_port": BOOKSTACK_PORT,
|
||||
"openwebui_port": OPENWEBUI_PORT,
|
||||
"portainer_port": PORTAINER_PORT,
|
||||
},
|
||||
)
|
||||
|
||||
@app.get("/about", response_class=HTMLResponse)
|
||||
async def about(request: Request):
|
||||
return templates.TemplateResponse("about.html", {"request": request})
|
||||
# Load courses from CSV
|
||||
courses = []
|
||||
if COURSES_CSV.exists():
|
||||
try:
|
||||
with open(COURSES_CSV, 'r', encoding='utf-8') as f:
|
||||
reader = csv.DictReader(f)
|
||||
courses = list(reader)
|
||||
except Exception as e:
|
||||
print(f"Error loading courses: {e}")
|
||||
|
||||
return templates.TemplateResponse("about.html", {
|
||||
"request": request,
|
||||
"courses": courses
|
||||
})
|
||||
|
||||
@app.get("/cost", response_class=HTMLResponse)
|
||||
async def cost_dashboard(request: Request):
|
||||
|
|
@ -127,11 +155,14 @@ def send_order_endpoint(
|
|||
|
||||
analysis = analyze_pdf(path)
|
||||
|
||||
# Get Matrix room ID from environment
|
||||
matrix_room = os.environ.get("MATRIX_ROOM", "!eFWbWEnYsgeIKqyfjw:einszwovier.local")
|
||||
|
||||
try:
|
||||
send_order_sync(
|
||||
pdf_path=path,
|
||||
analysis=analysis,
|
||||
room_id="!eFWbWEnYsgeIKqyfjw:einszwovier.local",
|
||||
room_id=matrix_room,
|
||||
name=name,
|
||||
comment=comment,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue