Toggle Navigation
Hatchery
Eggs
Websockets test
network_lib.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
network_lib.py
raw
Content
import urequests as requests import gc import uwebsockets.client def sendGET(url, debug = False): r = requests.get(url) gc.collect() data = r.json() r.close() if(debug): print("Response from GET " + url) print(data) return data def sendPOST(url, dataDictionary, debug = False): r = requests.post(url, json = dataDictionary) gc.collect() response = r.status_code r.close() if(debug): print("Status code from POST " + url) print(response) return response def connectWebsocket(): with uwebsockets.client.connect('wss://echo.websocket.org') as websocket: websocket.send("SHA2017 BADGE FULLY OPERATIONAL") print("> {}".format("SHA2017 BADGE FULLY OPERATIONAL")) greeting = websocket.recv() print("< {}".format(greeting))