Debian Codegraph @

docs/examples/todo_app/get_list/dataclass.py

raw
1 from dataclasses import dataclass
2 from typing import List
3
4 from litestar import Litestar, get
5
6
7 @dataclass
8 class TodoItem:
9 title: str
10 done: bool
11
12
13 TODO_LIST: List[TodoItem] = [
14 TodoItem(title="Start writing TODO list", done=True),
15 TodoItem(title="???", done=False),
16 TodoItem(title="Profit", done=False),
17 ]
18
19
20 @get("/")
21 async def get_list() -> List[TodoItem]:
22 return TODO_LIST
23
24
25 app = Litestar([get_list])