from fastapi import FastAPI, Request from fastapi.responses import HTMLResponse # <--- Add this import from env import FinAuditEnv import os app = FastAPI() # Initialize your environment natively env_instance = FinAuditEnv() # 🚨 THE FIX: Serve the beautiful HTML dashboard to humans @app.get("/", response_class=HTMLResponse) def home(): # Fallback message just in case index.html is missing if not os.path.exists("index.html"): return "

FinAuditEnv is Live! (index.html missing)

" with open("index.html", "r") as f: return f.read() @app.get("/health") def health(): return {"status": "ok"} @app.post("/reset") async def reset_env(request: Request): payload = await request.json() if await request.body() else {} task = payload.get("task_name", "finaudit_complex") obs = env_instance.reset(task) return {"observation": obs} @app.post("/step") async def step_env(request: Request): payload = await request.json() action = payload.get("action") if "action" in payload else payload obs, reward, done = env_instance.step(action) return {"observation": obs, "reward": reward, "done": done} @app.get("/state") async def get_state(): return {"state": "active"}