astro21 commited on
Commit
e097cb7
·
1 Parent(s): 59d9679

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -0
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):