🎯 FINAL FIX: Projekt-Ansicht für /projects/{name} + absolute URLs im UI
docker-build-and-push / build (push) Successful in 17s
docker-build-and-push / build (push) Successful in 17s
This commit is contained in:
+34
-1
@@ -30,4 +30,37 @@ TEMPLATES_DIR = Path(__file__).parent / "templates"
|
||||
@app.get("/", response_class=HTMLResponse)
|
||||
async def dashboard(request: Request):
|
||||
with open(TEMPLATES_DIR / "index.html") as f:
|
||||
return f.read()
|
||||
return f.read()
|
||||
|
||||
|
||||
@app.get("/projects/{project_name}") # ✅ Fuer direkten Zugriff auf Projekte!
|
||||
def project_view(project_name: str, request: Request):
|
||||
"""Gibt ein einfaches Verzeichnis-Display zurueck."""
|
||||
from fastapi.responses import HTMLResponse
|
||||
|
||||
target_dir = PROJECTS_DIR / project_name
|
||||
|
||||
if not target_dir.exists():
|
||||
return {"error": "Projekt nicht gefunden", "available_projects": [p.name for p in PROJECTS_DIR.iterdir() if p.is_dir()]}
|
||||
|
||||
# Einfache HTML-Ansicht:
|
||||
html = f"""<!DOCTYPE html>
|
||||
<html><head><title>{project_name}</title>
|
||||
<style>body{{font-family:sans-serif;padding:20px;background:#f5f5f5}}
|
||||
.file {{background:white;margin:10px 0;padding:15px;border-radius:8px;box-shadow:0 2px 4px rgba(0,0,0,.1);cursor:pointer}}
|
||||
.dir {{font-weight:bold}} a{{color:#007bff;text-decoration:none}}</style>
|
||||
</head><body>
|
||||
<h1>📁 {project_name}</h1>
|
||||
<h3>Dateien:</h3>
|
||||
<a href="/"><button style="margin:10px 0">🏠 Zurueck zum Dashboard</button></a>
|
||||
"""
|
||||
|
||||
if (target_dir / '.git').exists():
|
||||
html += '<p style="color:#28a745">✅ Git Repository</p>'
|
||||
|
||||
for item in sorted(target_dir.iterdir()):
|
||||
icon = "📁" if item.is_dir() else "📄"
|
||||
link = f"/projects/{item.name}" if item.is_dir() else "#"
|
||||
html += f'<div class="file {"" if item.is_file() else "dir"}"><a href="{link}">{icon} {item.name}</a></div>'
|
||||
|
||||
return HTMLResponse(html)
|
||||
Reference in New Issue
Block a user