Update main.py
Browse files
main.py
CHANGED
|
@@ -1,8 +1,17 @@
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from gradio_client import Client
|
|
|
|
| 3 |
|
| 4 |
app = FastAPI()
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# Define a route for the prediction using FastAPI
|
| 7 |
@app.post("/predict")
|
| 8 |
async def predict(text: str):
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from gradio_client import Client
|
| 3 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 4 |
|
| 5 |
app = FastAPI()
|
| 6 |
|
| 7 |
+
# Add CORS middleware to allow requests from any origin (for development)
|
| 8 |
+
app.add_middleware(
|
| 9 |
+
CORSMiddleware,
|
| 10 |
+
allow_origins=["*"],
|
| 11 |
+
allow_methods=["*"],
|
| 12 |
+
allow_headers=["*"],
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
# Define a route for the prediction using FastAPI
|
| 16 |
@app.post("/predict")
|
| 17 |
async def predict(text: str):
|