Spaces:
Sleeping
Sleeping
CORS modificaiton
Browse files
app.py
CHANGED
@@ -1,7 +1,21 @@
|
|
1 |
from fastapi import FastAPI
|
|
|
2 |
|
3 |
app = FastAPI()
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
@app.get("/")
|
6 |
def greet_json():
|
7 |
return {"Hello": "World!"}
|
|
|
1 |
from fastapi import FastAPI
|
2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
3 |
|
4 |
app = FastAPI()
|
5 |
|
6 |
+
origins = [
|
7 |
+
"http://localhost",
|
8 |
+
"http://localhost:8080",
|
9 |
+
]
|
10 |
+
|
11 |
+
app.add_middleware(
|
12 |
+
CORSMiddleware,
|
13 |
+
allow_origins=origins,
|
14 |
+
allow_credentials=True,
|
15 |
+
allow_methods=["*"],
|
16 |
+
allow_headers=["*"],
|
17 |
+
)
|
18 |
+
|
19 |
@app.get("/")
|
20 |
def greet_json():
|
21 |
return {"Hello": "World!"}
|