feat: Implement initial FastAPI application structure with configuration, core services, and an admin UI.

This commit is contained in:
2026-01-29 13:15:26 +08:00
parent 9cb938be9a
commit a5300eb379
4 changed files with 22 additions and 5 deletions

View File

@@ -14,5 +14,7 @@ class Settings:
ALGORITHM: str = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60
ADMIN_PASSWORD: str = os.getenv("ADMIN_PASSWORD", "admin123")
ENVIRONMENT: str = os.getenv("ENVIRONMENT", "development")
settings = Settings()

View File

@@ -17,7 +17,16 @@ from app.api.endpoints import auth
from app.api import admin_backend
def create_application() -> FastAPI:
application = FastAPI(title=settings.PROJECT_NAME)
# Disable docs and redoc in production
docs_url = "/docs" if settings.ENVIRONMENT == "development" else None
redoc_url = "/redoc" if settings.ENVIRONMENT == "development" else None
application = FastAPI(
title=settings.PROJECT_NAME,
docs_url=docs_url,
redoc_url=redoc_url
)
# Mount Static Files
application.mount("/static", StaticFiles(directory="app/static"), name="static")
@@ -53,4 +62,8 @@ async def admin_panel():
@app.get("/")
async def root():
return {"message": "Welcome to Storyline AI Gateway", "docs": "/docs"}
response = {"message": "Welcome to Storyline AI Gateway"}
if settings.ENVIRONMENT == "development":
response["docs"] = "/docs"
return response

View File

@@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Storyline AI Gateway - Admin</title>
<title>AI Gateway - Admin</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap" rel="stylesheet">
@@ -398,7 +398,7 @@
<div class="bg-gradient"></div>
<div class="container">
<header>
<div class="logo">Storyline Gateway Admin</div>
<div class="logo">AI Gateway Admin</div>
<button id="logout-btn" class="btn-small btn-outline hidden">Logout</button>
</header>

View File

@@ -6,4 +6,6 @@ load_dotenv()
if __name__ == "__main__":
port = int(os.getenv("PORT", 8000))
uvicorn.run("app.main:app", host="0.0.0.0", port=port, reload=True)
is_development = os.getenv("ENVIRONMENT", "development") == "development"
uvicorn.run("app.main:app", host="0.0.0.0", port=port, reload=is_development)