Spaces:
Sleeping
Sleeping
Download routers/practices.py from Coeinterns/bank-statement-api: direct link, hf CLI and curl.
- Browser
- Download file 585 Bytes
-
https://huggingface.co/spaces/Coeinterns/bank-statement-api/resolve/main/routers/practices.py
- Command line
-
hf download hf://spaces/Coeinterns/bank-statement-api/routers/practices.py
-
curl -L -o practices.py https://huggingface.co/spaces/Coeinterns/bank-statement-api/resolve/main/routers/practices.py
585 Bytes
| from fastapi import APIRouter | |
| from auth.database import SessionLocal | |
| from auth.rule_models import Practice | |
| router = APIRouter(tags=["practices"]) | |
| async def get_practices(): | |
| """Return all active practices for the dropdown seed.""" | |
| db = SessionLocal() | |
| try: | |
| practices = ( | |
| db.query(Practice) | |
| .filter(Practice.is_active == True) | |
| .order_by(Practice.name.asc()) | |
| .all() | |
| ) | |
| return {"practices": [{"id": p.id, "name": p.name} for p in practices]} | |
| finally: | |
| db.close() | |