Spaces:
Sleeping
Sleeping
File size: 1,493 Bytes
ef93755 7257069 ef93755 7257069 ef93755 7257069 ef93755 7257069 ef93755 7257069 ef93755 7257069 ef93755 7257069 ef93755 7257069 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | """
SecureCodeEnv - FastAPI Application Entry Point
Built for Meta x PyTorch OpenEnv Hackathon 2026
Author: Vishal Dhakad (vishaldhakad)
"""
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from fastapi.middleware.cors import CORSMiddleware
from app.routes import router
from app.models import HealthResponse
from app.dashboard import DASHBOARD_HTML
from tasks.task_registry import TASK_REGISTRY
app = FastAPI(
title="SecureCodeEnv",
description=(
"An RL environment for training LLM agents to write production-ready, secure Python code. "
"Agents are graded on correctness, attack resistance, CWE-based static analysis, "
"performance, and codebase consistency via a novel CodeGraph memory system."
),
version="2.0.0",
docs_url="/docs",
redoc_url="/redoc",
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(router)
@app.get("/health", response_model=HealthResponse, tags=["System"])
def health():
"""Health check — required by hackathon automated ping."""
return HealthResponse(
status="ok",
env="SecureCodeEnv",
version="2.0.0",
tasks_loaded=len(TASK_REGISTRY),
)
@app.get("/", response_class=HTMLResponse, include_in_schema=False)
def root():
"""HTML dashboard — shown on HuggingFace Spaces landing page."""
return HTMLResponse(content=DASHBOARD_HTML, status_code=200)
|