Coverage for src/dev.py: 0%
20 statements
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-12 06:31 -0700
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-12 06:31 -0700
1from collections.abc import Iterable
3import uvicorn
4from extratools_core.json import JsonDict
5from fastapi import FastAPI
7from extratools_api.crudl import add_crudl_endpoints
9app = FastAPI()
11store: dict[str, JsonDict] = {}
14async def create_func(key: str, value: JsonDict) -> None:
15 store[key] = value
18async def read_func(key: str) -> JsonDict:
19 return store[key]
22async def update_func(key: str, value: JsonDict) -> None:
23 store[key] = value
26async def delete_func(key: str) -> None:
27 del store[key]
30async def list_func(_: JsonDict | None) -> Iterable[tuple[str, JsonDict]]:
31 return store.items()
34add_crudl_endpoints(
35 app,
36 create_func=create_func,
37 read_func=read_func,
38 update_func=update_func,
39 delete_func=delete_func,
40 list_func=list_func,
41 path_prefix="/items",
42)
45if __name__ == "__main__":
46 uvicorn.run(app, host="0.0.0.0", port=8000)