This introduces the FastAPI editor implementation and related project setup so the app can be run and validated locally. Made-with: Cursor
29 lines
872 B
Python
29 lines
872 B
Python
from fastapi import FastAPI
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
from editor_app.config import STATIC_DIR, WORKSPACE_ROOT
|
|
from editor_app.routers.files import router as files_router
|
|
from editor_app.routers.frontend import router as frontend_router
|
|
from editor_app.routers.python_exec import router as python_router
|
|
|
|
|
|
def create_app() -> FastAPI:
|
|
app = FastAPI()
|
|
app.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static")
|
|
app.include_router(frontend_router)
|
|
app.include_router(files_router)
|
|
app.include_router(python_router)
|
|
|
|
@app.on_event("startup")
|
|
async def run_configured_startup_script() -> None:
|
|
from editor_app.services import python_runner
|
|
|
|
(WORKSPACE_ROOT / "lib").mkdir(parents=True, exist_ok=True)
|
|
python_runner.run_startup_script_if_configured()
|
|
|
|
return app
|
|
|
|
|
|
app = create_app()
|
|
|