32 lines
791 B
Python
32 lines
791 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
import yaml
|
|
from pathlib import Path
|
|
|
|
app = FastAPI()
|
|
# Allow CORS for all origins
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {"message": "Welcome to the FastAPI application!"}
|
|
|
|
# Path to apps.yaml (relative to backend/)
|
|
APPS_FILE = Path(__file__).parent / "apps.yaml"
|
|
|
|
@app.get("/apps")
|
|
def get_apps():
|
|
if not APPS_FILE.exists():
|
|
return {"error": "apps.yaml not found"}
|
|
with open(APPS_FILE, "r") as f:
|
|
return yaml.safe_load(f)
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) |