Spaces:
Sleeping
Sleeping
Create proxy.py
Browse files
proxy.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, File, UploadFile
|
| 2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
+
import requests
|
| 4 |
+
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
# Allow local frontend (adjust if needed)
|
| 8 |
+
app.add_middleware(
|
| 9 |
+
CORSMiddleware,
|
| 10 |
+
allow_origins=["*"],
|
| 11 |
+
allow_methods=["*"],
|
| 12 |
+
allow_headers=["*"],
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
@app.post("/analyze/")
|
| 16 |
+
async def analyze_video(file: UploadFile = File(...)):
|
| 17 |
+
files = {"data": (file.filename, await file.read(), file.content_type)}
|
| 18 |
+
response = requests.post("https://hf.space/embed/Mrinal007/Facial_engagement/+/api/predict/", files=files)
|
| 19 |
+
return response.json()
|