Spaces:
Runtime error
Runtime error
phuochungus
commited on
Commit
•
f2ef468
1
Parent(s):
8fab380
enable cors
Browse files- app/server.py +13 -1
app/server.py
CHANGED
@@ -1,11 +1,23 @@
|
|
1 |
-
from fastapi import
|
2 |
from fastapi.responses import RedirectResponse
|
3 |
from langserve import add_routes
|
|
|
4 |
|
5 |
from rag_redis.chain import chain as rag_redis_chain
|
6 |
|
7 |
app = FastAPI()
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
@app.get("/")
|
11 |
async def redirect_root_to_docs():
|
|
|
1 |
+
from fastapi.middleware.cors import CORSMiddleware
|
2 |
from fastapi.responses import RedirectResponse
|
3 |
from langserve import add_routes
|
4 |
+
from fastapi import FastAPI
|
5 |
|
6 |
from rag_redis.chain import chain as rag_redis_chain
|
7 |
|
8 |
app = FastAPI()
|
9 |
|
10 |
+
origins = ["*"]
|
11 |
+
|
12 |
+
app.add_middleware(
|
13 |
+
CORSMiddleware,
|
14 |
+
allow_origins=origins,
|
15 |
+
allow_credentials=True,
|
16 |
+
allow_methods=["*"],
|
17 |
+
allow_headers=["*"],
|
18 |
+
)
|
19 |
+
|
20 |
+
|
21 |
|
22 |
@app.get("/")
|
23 |
async def redirect_root_to_docs():
|