Schwester-Projekt zu arduino.lehrstun.de fuer die 3D-Druck-AG am Lessing-Gymnasium. Offene jahrelange Nachmittags-AG (kein Trimester), 8-10 Einzel-SuS mit optionalen 2er-Paarungen, 4 Bambu-Lab-Drucker (3 geschlossen + 1 A1 mini). Konzept v2 (Reality-Check-Iteration 2026-05-24): - Onboarding-Pfad statt Pflicht-Lektionen (L1-L3 selbst-zertifiziert) - Selbstlern-Loop als Kern: SuS-Projekte wachsen die interne Bibliothek - Drill-Down-Lehrer-Dashboard (Wer ist hier / Wartet Review / Haengt fest) - Cockpit progressiv: zeigt nur was zum Status passt - Bambu-Cloud-API fuer Drucker-Live-Status (fragil + Fallback manuell) - Three.js-Vorschau fuer Cover-aus-3D-Ansicht (Etappe 6) - Vollstaendige Doku als Obsidian-Vault (24 Markdown-Dateien) - Entscheidungen E-001 bis E-022 in docs/decisions.md Etappe 1 lauffaehig (~1800 Zeilen Code): - Blueprint-Struktur (V8): routes/oeffentlich+profil+admin+api, services/auth+bambu+datei - Komplettes Schema in database.py (14 Tabellen, idempotent) - Login mit bcrypt + persistentem Lockout in DB (V7, verbessert ggue Arduino-Kurs der In-Memory-Dict nutzt) - Admin-Login + Profile-CRUD + PIN-Reset + PIN-Karten-Druckbogen - Inline-Edit-Endpunkt mit Whitelist + Audit-Log - Seeds: AG lessing-3d-ag + 4 Drucker + Default-Einstellungen - Smoke-Test bestanden (Login, Profil-Anlage, Lockout-Logging) Nicht im Repo (.gitignore): .env, *.db, venv/, .obsidian/workspace.json
91 lines
2.4 KiB
Python
91 lines
2.4 KiB
Python
"""3D-Druck-AG — Flask-Bootstrap.
|
|
|
|
Nach V8 (siehe docs/decisions.md#E-020): Blueprint-Struktur.
|
|
Diese Datei laedt die Konfiguration, registriert Blueprints, definiert
|
|
Context-Processor + Error-Handler.
|
|
|
|
Routen leben in routes/. Externe Services in services/.
|
|
|
|
Quickstart (lokal):
|
|
python -c "from database import init_db; init_db()"
|
|
python seed.py
|
|
python app.py # http://localhost:5057
|
|
"""
|
|
import os
|
|
from pathlib import Path
|
|
|
|
from dotenv import load_dotenv
|
|
from flask import Flask, render_template, request
|
|
|
|
from tiere import tier_emoji, tier_name
|
|
|
|
# Routes-Blueprints
|
|
from routes.oeffentlich import bp as bp_oeffentlich
|
|
from routes.profil import bp as bp_profil
|
|
from routes.admin import bp as bp_admin
|
|
from routes.api import bp as bp_api
|
|
|
|
load_dotenv()
|
|
|
|
app = Flask(__name__)
|
|
app.secret_key = os.environ.get("FLASK_SECRET", "dev-key-bitte-aendern")
|
|
|
|
# Blueprints registrieren
|
|
app.register_blueprint(bp_oeffentlich)
|
|
app.register_blueprint(bp_profil)
|
|
app.register_blueprint(bp_admin)
|
|
app.register_blueprint(bp_api)
|
|
|
|
|
|
# ===========================================================================
|
|
# Markdown-Filter fuer Templates (Pattern wie arduino.lehrstun.de)
|
|
# ===========================================================================
|
|
import markdown as _markdown
|
|
|
|
|
|
@app.template_filter("markdown")
|
|
def markdown_filter(text):
|
|
if not text:
|
|
return ""
|
|
return _markdown.markdown(
|
|
text,
|
|
extensions=["fenced_code", "tables", "nl2br"],
|
|
output_format="html5",
|
|
)
|
|
|
|
|
|
# ===========================================================================
|
|
# Context-Processor: in jedem Template verfuegbar
|
|
# ===========================================================================
|
|
|
|
@app.context_processor
|
|
def inject_globals():
|
|
return {
|
|
"tier_emoji": tier_emoji,
|
|
"tier_name": tier_name,
|
|
}
|
|
|
|
|
|
# ===========================================================================
|
|
# Error-Handler
|
|
# ===========================================================================
|
|
|
|
@app.errorhandler(404)
|
|
def err_404(e):
|
|
return render_template("404.html"), 404
|
|
|
|
|
|
@app.errorhandler(500)
|
|
def err_500(e):
|
|
return render_template("500.html"), 500
|
|
|
|
|
|
@app.errorhandler(501)
|
|
def err_501(e):
|
|
return render_template("501.html"), 501
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# Port 5057 (5055 = quiz-collector, 5056 = arduino-db)
|
|
app.run(host="0.0.0.0", port=5057, debug=True)
|