Seth0330 commited on
Commit
3bdbb36
·
verified ·
1 Parent(s): 80271d1

Create backend/app/main.py

Browse files
Files changed (1) hide show
  1. backend/app/main.py +22 -0
backend/app/main.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+
4
+ app = FastAPI()
5
+
6
+ # In HF Spaces, frontend and backend are served from same origin if proxied,
7
+ # but keep CORS permissive for dev.
8
+ app.add_middleware(
9
+ CORSMiddleware,
10
+ allow_origins=["*"],
11
+ allow_credentials=True,
12
+ allow_methods=["*"],
13
+ allow_headers=["*"],
14
+ )
15
+
16
+ @app.get("/api/health")
17
+ def health():
18
+ return {"status": "ok"}
19
+
20
+ @app.get("/api/hello")
21
+ def hello():
22
+ return {"message": "Hello from FastAPI"}