Spaces:
Runtime error
Runtime error
refactor(app): allows cors
Browse files
app.py
CHANGED
|
@@ -1,8 +1,17 @@
|
|
| 1 |
from fastapi import FastAPI
|
|
|
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
# Create a new FastAPI app instance
|
| 4 |
app = FastAPI()
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# Initialize the text generation pipeline
|
| 7 |
# This function will be able to generate text
|
| 8 |
# given an input.
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
+
|
| 4 |
from transformers import pipeline
|
| 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.
|