Update web.py

This commit is contained in:
akp 2022-11-08 02:28:19 +00:00
parent bd5d0f26e9
commit b44f25fd74
No known key found for this signature in database
GPG key ID: AA5726202C8879B7

View file

@ -60,13 +60,6 @@ class WatchState:
ntfy_topic: str
machine_number: str
def _to_dict(self) -> Dict[str, str]:
return {
"site_id": self.site_id,
"ntfy_topic": self.ntfy_topic,
"machine_number": self.machine_number,
}
jobs: List[WatchState] = []
job_lock = Lock()
@ -80,10 +73,11 @@ def _api_register_watcher(site_id: str) -> Union[any, Tuple[any, int]]:
return flask.jsonify({"ok": False, "message": "missing machine_number"}), 400
job_lock.acquire()
jobs.append(WatchState(site_id, ntfy_topic, machine_number))
ws = WatchState(site_id, ntfy_topic, machine_number)
jobs.append(ws)
job_lock.release()
return "", 204
return flask.jsonify(ws), 204
def _api_list_watched() -> Union[any, Tuple[any, int]]: