diff options
| author | altaf-creator <dev@altafcreator.com> | 2025-12-29 20:25:08 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2025-12-29 20:25:08 +0800 |
| commit | 9080a0c516378dbb94c5178fbc26a8131a530263 (patch) | |
| tree | 5f3aff1737d00ab01852daea742f1c5dfe982b1d /backend/main.py | |
| parent | 37b76b0f4c8e65b35bbbc617bcbff7a5d637ac3e (diff) | |
new notif everything
Diffstat (limited to 'backend/main.py')
| -rw-r--r-- | backend/main.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/backend/main.py b/backend/main.py index d77fdd1..fec436b 100644 --- a/backend/main.py +++ b/backend/main.py @@ -17,6 +17,7 @@ from enum import Enum, IntEnum from dotenv import load_dotenv from os import getenv import yaml +import notif # import notif.py # ## API, db, and scheduler initialisation app = fastapi.FastAPI(title="Victoria Hall LaundryWeb", description="LaundryWeb Backend API", version="0.1") @@ -443,3 +444,14 @@ def uri_to_information(data: InformationRequestData, response: fastapi.Response, return "NO INFORMATION PROVIDED. NO AUTH COOKIE." return {"block": info[0], "machine": info[1]} + + +# #### NOTIFICATION API END POINTS #### + + +# --- subscribe +@app.post("/notif_subscribe") +def notif_subscribe(data: notif.PushSubscriptionData, response: fastapi.Response): + endpoint = notif.subscribe(data) + response.set_cookie("subscription_endpoint", endpoint) + response.status_code = fastapi.status.HTTP_200_OK |
