Coverage for app/demo.py: 87%

17 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-19 10:29 +0000

1from logging import getLogger 

2from typing import Annotated 

3 

4from fastapi import FastAPI, Query 

5 

6logger = getLogger(__name__) 

7app = FastAPI() 

8 

9 

10@app.get("/") 

11def get_index() -> str: 

12 return "Amazing." 

13 

14 

15@app.get("/hello") 

16def get_hello(name: Annotated[str, Query()] = "World") -> str: 

17 match name: 

18 # case "Bernd": 

19 # logger.warn("Bernd was here.") 

20 # return "Bye." 

21 case "Janosch": 21 ↛ 22line 21 didn't jump to line 22 because the pattern on line 21 never matched

22 logger.info("The cat was here.") 

23 return "Meow." 

24 case _: 

25 logger.info("%s was here.") 

26 return f"Hello {name}."