Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit ·
97655dc
1
Parent(s): fb361f9
Beta 1.0: Cloud Isolation (Fix Imports + .dockerignore + Safety Guard)
Browse filesFiles changed (3)
- .dockerignore+5
- core/config.py+7-1
- main.py+1-19
11 unmodified lines12131415161711 unmodified lines**/node_modules/logs/*.loguploads/*.Project guidelinesDockerfiledocker-compose.yml11 unmodified lines121314151617181920212211 unmodified lines**/node_modules/logs/*.loguploads/*# Environment Secrets (DO NOT INCLUDE IN CLOUD).env.env.*# Project Metadata & Tooling.Project guidelinesDockerfiledocker-compose.yml
28 unmodified lines2930313233343536373828 unmodified lines@propertydef async_database_url(self) -> str:"""Constructs or ensures the +asyncpg prefix exists for SQLAlchemy."""# Clean the input URL to handle accidental newlines from cloud secretsurl = self.DATABASE_URL.strip() if self.DATABASE_URL else Noneif url:if url.startswith("postgresql://"):return url.replace("postgresql://", "postgresql+asyncpg://", 1)return url28 unmodified lines2930313233343536373839404142434428 unmodified lines@propertydef async_database_url(self) -> str:"""Constructs or ensures the +asyncpg prefix exists for SQLAlchemy."""# Priority: Explicit environment variable DATABASE_URL (Cleaned)url = self.DATABASE_URL.strip() if self.DATABASE_URL else Noneif url:if "localhost" in url or "127.0.0.1" in url:# If we are in the cloud (Linux) but hitting localhost, something is wrongimport platformif platform.system() != "Windows":print("--- WARNING: CLOUD ENVIRONMENT DETECTED LOCALHOST DB ---")if url.startswith("postgresql://"):return url.replace("postgresql://", "postgresql+asyncpg://", 1)return url
1 unmodified line234567858 unmodified lines6768697071727374757677787980818283848586878889901 unmodified linefrom fastapi.middleware.cors import CORSMiddlewarefrom core.config import get_settingsfrom core.database import engine, run_migrationsfrom core.logging import setup_loggingfrom contextlib import asynccontextmanagerfrom models import Workspace # Triggers models/__init__.py for Base.metadata registration58 unmodified linesapp.include_router(system.router, prefix=f"{settings.API_V1_STR}/system", tags=["System Diagnostics"])app.include_router(websockets.router, tags=["websockets"])from fastapi import Requestfrom fastapi.responses import JSONResponsefrom core.logging import get_loggerlogger = get_logger(__name__)@app.exception_handler(Exception)async def global_exception_handler(request: Request, exc: Exception):logger.error(f"GLOBAL ERROR: {str(exc)}", exc_info=True)return JSONResponse(status_code=500,content={"detail": "An internal system error occurred. Our team has been notified.","error_type": type(exc).__name__,"message": str(exc) if settings.DEBUG else "Please try again later."})@app.get("/health", tags=["System"])def health_check():return {"status": "ok"}1 unmodified line234567858 unmodified lines6768697071721 unmodified linefrom fastapi.middleware.cors import CORSMiddlewarefrom core.config import get_settingsfrom core.database import engine, run_migrationsfrom core.logging import setup_logging, get_loggerfrom contextlib import asynccontextmanagerfrom models import Workspace # Triggers models/__init__.py for Base.metadata registration58 unmodified linesapp.include_router(system.router, prefix=f"{settings.API_V1_STR}/system", tags=["System Diagnostics"])app.include_router(websockets.router, tags=["websockets"])@app.get("/health", tags=["System"])def health_check():return {"status": "ok"}
.dockerignore+5
core/config.py+7-1
main.py+1-19