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