Advertisement
DOGGYWOOF

Doggy OS Webpage loader

Jul 25th, 2024 (edited)
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. local function loadWebsite()
  2. local filePath = "web.code"
  3. if not fs.exists(filePath) then
  4. return nil
  5. end
  6. local file = fs.open(filePath, "r")
  7. local code = file.readAll()
  8. file.close()
  9. return code
  10. end
  11.  
  12. rednet.open("top") -- Assuming the modem is on the top
  13. print("Webserver running...")
  14.  
  15. while true do
  16. local senderID, message = rednet.receive()
  17. if message == "GET" then
  18. local code = loadWebsite()
  19. if code then
  20. rednet.send(senderID, code)
  21. else
  22. rednet.send(senderID, "Website not found.")
  23. end
  24. end
  25. end
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement