-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathviews.py
More file actions
35 lines (25 loc) · 760 Bytes
/
Copy pathviews.py
File metadata and controls
35 lines (25 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import json
from pathlib import Path
from fastapi import APIRouter, Depends
from lnbits.core.views.generic import index
from lnbits.decorators import check_user_exists
def _load_version() -> str:
config_path = Path(__file__).parent / "config.json"
try:
with config_path.open() as f:
return json.load(f).get("version", "unknown")
except Exception:
return "unknown"
__version__ = _load_version()
decoder_generic_router: APIRouter = APIRouter()
decoder_generic_router.add_api_route(
"/",
methods=["GET"],
endpoint=index,
dependencies=[Depends(check_user_exists)],
)
decoder_generic_router.add_api_route(
"/api/v1/version",
methods=["GET"],
endpoint=lambda: {"version": __version__},
)