Nrighton233j
Add stateless JOY endpoint for search summaries — https://huggingface.co/spaces/Brighton233j/Messenger_back_database
f71fc0d
Raw
History Blame Contribute Delete
830 Bytes
import socketio
import time
TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEsInVzZXJuYW1lIjoidGVzdHVzZXIiLCJpYXQiOjE3ODMxODU0OTEsImV4cCI6MTc4NTc3NzQ5MX0.02ooFo1eRDfz0Wlsz9kzVFVkDIMLbCw_eZ8YrOw3P9g"
BASE_URL = "https://Brighton233j-Messenger-back-database.hf.space"
sio = socketio.Client()
@sio.event
def connect():
print("Connected! Sending message to JOY...")
sio.emit("send_message", {
"token": TOKEN,
"recipient_id": 0,
"content": "Hey JOY, are you working?"
})
@sio.on("new_message")
def on_message(data):
print(f"[msg] sender_id={data['sender_id']}: {data['content']}")
@sio.event
def connect_error(data):
print("Connection failed:", data)
sio.connect(f"{BASE_URL}?token={TOKEN}", socketio_path="/socket.io", transports=["websocket"])
time.sleep(6)
sio.disconnect()