mirror of https://github.com/tiangolo/fastapi.git
25 lines
459 B
Python
25 lines
459 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
app = FastAPI()
|
|
|
|
origins = [
|
|
"http://localhost.tiangolo.com",
|
|
"https://localhost.tiangolo.com",
|
|
"http://localhost",
|
|
"http://localhost:8080",
|
|
]
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
|
|
@app.get("/")
|
|
async def main():
|
|
return {"message": "Hello World"}
|