Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- Dockerfile +11 -0
- main.py +17 -0
- requirements.txt +3 -0
Dockerfile
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
|
| 3 |
+
# Install dependencies
|
| 4 |
+
COPY requirements.txt .
|
| 5 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 6 |
+
|
| 7 |
+
# Copy all project files into the container root
|
| 8 |
+
COPY . .
|
| 9 |
+
|
| 10 |
+
# Run FastAPI app
|
| 11 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
main.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Request
|
| 2 |
+
import httpx
|
| 3 |
+
|
| 4 |
+
app = FastAPI(title="Mintzy API Proxy", version="1.0")
|
| 5 |
+
|
| 6 |
+
GCP_API_URL = "http://34.63.74.181:8080/predict" # Your GCP FastAPI endpoint
|
| 7 |
+
|
| 8 |
+
@app.get("/")
|
| 9 |
+
def root():
|
| 10 |
+
return {"message": "Mintzy API proxy is running"}
|
| 11 |
+
|
| 12 |
+
@app.post("/predict")
|
| 13 |
+
async def predict(request: Request):
|
| 14 |
+
payload = await request.json()
|
| 15 |
+
async with httpx.AsyncClient() as client:
|
| 16 |
+
response = await client.post(GCP_API_URL, json=payload)
|
| 17 |
+
return response.json()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn
|
| 3 |
+
httpx
|