jsvs commited on
Commit
9832cc7
·
1 Parent(s): 68bdf3d

refactor(app): allowing cors

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -1,9 +1,17 @@
1
  from fastapi import FastAPI
2
  from transformers import pipeline
3
-
 
4
  # Create a new FastAPI app instance
5
  app = FastAPI()
6
-
 
 
 
 
 
 
 
7
  # Initialize the text generation pipeline
8
  # This function will be able to generate text
9
  # given an input.
 
1
  from fastapi import FastAPI
2
  from transformers import pipeline
3
+ from fastapi.middleware.cors import CORSMiddleware
4
+
5
  # Create a new FastAPI app instance
6
  app = FastAPI()
7
+ origins = ["*"]
8
+ app.add_middleware(
9
+ CORSMiddleware,
10
+ allow_origins=origins,
11
+ allow_credentials=True,
12
+ allow_methods=["*"],
13
+ allow_headers=["*"],
14
+ )
15
  # Initialize the text generation pipeline
16
  # This function will be able to generate text
17
  # given an input.