Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

Print backend debug status on start

Abi Rajac0c1adbe65c3
diff --git a/backend/main.py b/backend/main.py
index 192ef220..245b0f27 100644
--- a/backend/main.py
+++ b/backend/main.py
@@ -6,10 +6,17 @@ load_dotenv()
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
+from config import IS_DEBUG_ENABLED
from routes import screenshot, generate_code, home, evals
app = FastAPI(openapi_url=None, docs_url=None, redoc_url=None)
+
[email protected]_event("startup")
+async def log_debug_mode() -> None:
+ debug_status = "ENABLED" if IS_DEBUG_ENABLED else "DISABLED"
+ print(f"Backend startup complete. Debug mode is {debug_status}.")
+
# Configure CORS settings
app.add_middleware(
CORSMiddleware,
diff --git a/backend/routes/generate_code.py b/backend/routes/generate_code.py
index d2f8025e..dfa511a6 100644
--- a/backend/routes/generate_code.py
+++ b/backend/routes/generate_code.py
@@ -10,6 +10,7 @@ from codegen.utils import extract_html_content
from config import (
ANTHROPIC_API_KEY,
GEMINI_API_KEY,
+ IS_DEBUG_ENABLED,
IS_PROD,
NUM_VARIANTS,
NUM_VARIANTS_VIDEO,
@@ -729,13 +730,14 @@ class CodeGenerationMiddleware(Middleware):
anthropic_api_key=context.extracted_params.anthropic_api_key,
gemini_api_key=GEMINI_API_KEY,
)
- await context.send_message(
- "variantModels",
- None,
- 0,
- {"models": [model.value for model in context.variant_models]},
- None,
- )
+ if IS_DEBUG_ENABLED:
+ await context.send_message(
+ "variantModels",
+ None,
+ 0,
+ {"models": [model.value for model in context.variant_models]},
+ None,
+ )
generation_stage = AgenticGenerationStage(
send_message=context.send_message,