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

1from fastapi import FastAPI 1abcd

2from fastapi.middleware.cors import CORSMiddleware 1abcd

3 

4app = FastAPI() 1abcd

5 

6origins = [ 1abcd

7 "http://localhost.tiangolo.com", 

8 "https://localhost.tiangolo.com", 

9 "http://localhost", 

10 "http://localhost:8080", 

11] 

12 

13app.add_middleware( 1abcd

14 CORSMiddleware, 

15 allow_origins=origins, 

16 allow_credentials=True, 

17 allow_methods=["*"], 

18 allow_headers=["*"], 

19) 

20 

21 

22@app.get("/") 1abcd

23async def main(): 1abcd

24 return {"message": "Hello World"} 1efg