Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -111,21 +111,21 @@ async def websocket_notifications(ws: WebSocket, username: str, db: Session = De
|
|
| 111 |
APIs for Gradio Interfaces
|
| 112 |
"""
|
| 113 |
def register_user(username):
|
| 114 |
-
url = "http://127.0.0.1:
|
| 115 |
response = requests.post(url, json={"username": username})
|
| 116 |
if response.status_code != 200:
|
| 117 |
return f"Failed to register user. Status code: {response.status_code}", ""
|
| 118 |
return response.json().get("username", ""), response.json().get("token", "")
|
| 119 |
|
| 120 |
def send_notification(token, title, message):
|
| 121 |
-
url = "http://127.0.0.1:
|
| 122 |
response = requests.post(url, json={"token": token, "title": title, "message": message})
|
| 123 |
if response.status_code != 200:
|
| 124 |
return f"Failed to send notification. Status code: {response.status_code}"
|
| 125 |
return f"Notification sent to user with token ending in ...{token[-4:]}"
|
| 126 |
|
| 127 |
def get_notifications(username):
|
| 128 |
-
url = f"http://127.0.0.1:
|
| 129 |
response = requests.get(url)
|
| 130 |
if response.status_code != 200:
|
| 131 |
return f"Failed to send notification. Status code: {response.status_code}", ""
|
|
|
|
| 111 |
APIs for Gradio Interfaces
|
| 112 |
"""
|
| 113 |
def register_user(username):
|
| 114 |
+
url = "http://127.0.0.1:7860/register_user"
|
| 115 |
response = requests.post(url, json={"username": username})
|
| 116 |
if response.status_code != 200:
|
| 117 |
return f"Failed to register user. Status code: {response.status_code}", ""
|
| 118 |
return response.json().get("username", ""), response.json().get("token", "")
|
| 119 |
|
| 120 |
def send_notification(token, title, message):
|
| 121 |
+
url = "http://127.0.0.1:7860/notify"
|
| 122 |
response = requests.post(url, json={"token": token, "title": title, "message": message})
|
| 123 |
if response.status_code != 200:
|
| 124 |
return f"Failed to send notification. Status code: {response.status_code}"
|
| 125 |
return f"Notification sent to user with token ending in ...{token[-4:]}"
|
| 126 |
|
| 127 |
def get_notifications(username):
|
| 128 |
+
url = f"http://127.0.0.1:7860/notifications/{username}"
|
| 129 |
response = requests.get(url)
|
| 130 |
if response.status_code != 200:
|
| 131 |
return f"Failed to send notification. Status code: {response.status_code}", ""
|