Files
tesla-order-bot-tr/wsserver.py
2025-07-22 23:22:14 +03:00

26 lines
723 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import json
from simple_websocket_server import WebSocketServer, WebSocket
clients = []
class TeslaDataServer(WebSocket):
def connected(self):
print(f"{self.address} bağlandı")
clients.append(self)
def handle_close(self):
print(f"{self.address} ayrıldı")
clients.remove(self)
def handle_message(self, message):
print(f"Gelen veri: {message[:80]}...")
for client in clients:
client.send_message(message)
def handle(self):
for client in clients:
client.send_message(self.data)
server = WebSocketServer('0.0.0.0', 8000, TeslaDataServer)
print("WebSocket sunucusu 8000 portunda başlatıldı.")
server.serve_forever()