-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
66 lines (49 loc) · 1.45 KB
/
main.py
File metadata and controls
66 lines (49 loc) · 1.45 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""
main.py — FastAPI application entry point.
Run:
uvicorn main:app --reload
"""
import logging
import os
from contextlib import asynccontextmanager
from dotenv import load_dotenv
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from fastapi.responses import RedirectResponse
load_dotenv()
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
)
from api.routes import router, get_orchestrator
@asynccontextmanager
async def lifespan(app: FastAPI):
get_orchestrator() # warm up on startup
yield
from api.routes import _orchestrator
if _orchestrator:
_orchestrator.shutdown()
app = FastAPI(
title="AutoCodeAI",
description="Multi-agent autonomous coding system with parallel execution, tool integration, and flexible LLM support.",
version="2.0.0",
lifespan=lifespan,
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(router, prefix="/api")
# Serve static files
app.mount("/static", StaticFiles(directory="static"), name="static")
@app.get("/", tags=["root"])
async def root():
"""Redirect to web UI."""
return RedirectResponse(url="/static/index.html")
@app.get("/health", tags=["health"])
async def health():
return {"status": "ok", "version": "2.0.0"}