supreamcallum45

Reator to web interface

Jan 9th, 2021 (edited)
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.51 KB | None | 0 0
  1. os.loadAPI("json")
  2. local ws, err = http.websocket("ws://5ffb03dfaa0d.ngrok.io/")
  3.  
  4. if err then
  5.     print(err)
  6. end
  7. if ws then
  8.     print("> CONNECTED")
  9.     while true do
  10.         local message = ws.receive()
  11.         print(message)
  12.         local obj = json.decode(message)
  13.         if obj.type == 'eval' then
  14.             local func = loadstring(obj['function'])
  15.             local result = func()
  16.             ws.send(json.encode(result))
  17.             print("> EVAL " .. tostring(result))
  18.         end
  19.     end
  20. end
  21.  
Add Comment
Please, Sign In to add comment