Coverage for docs_src / cors / tutorial001_py310.py: 100%
8 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
1from fastapi import FastAPI 1abcd
2from fastapi.middleware.cors import CORSMiddleware 1abcd
4app = FastAPI() 1abcd
6origins = [ 1abcd
7 "http://localhost.tiangolo.com",
8 "https://localhost.tiangolo.com",
9 "http://localhost",
10 "http://localhost:8080",
11]
13app.add_middleware( 1abcd
14 CORSMiddleware,
15 allow_origins=origins,
16 allow_credentials=True,
17 allow_methods=["*"],
18 allow_headers=["*"],
19)
22@app.get("/") 1abcd
23async def main(): 1abcd
24 return {"message": "Hello World"} 1efg