diff --git a/app/core/config.py b/app/core/config.py index 07393f8..6bd3384 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -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() diff --git a/app/main.py b/app/main.py index cd01a8f..93539d4 100644 --- a/app/main.py +++ b/app/main.py @@ -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 + diff --git a/app/static/admin.html b/app/static/admin.html index 8571ec9..c89da7a 100644 --- a/app/static/admin.html +++ b/app/static/admin.html @@ -4,7 +4,7 @@ - Storyline AI Gateway - Admin + AI Gateway - Admin @@ -398,7 +398,7 @@
- +
diff --git a/main.py b/main.py index 0db427d..3f5fdb0 100644 --- a/main.py +++ b/main.py @@ -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) +