Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function loadWebsite()
- local filePath = "web.code"
- if not fs.exists(filePath) then
- return nil
- end
- local file = fs.open(filePath, "r")
- local code = file.readAll()
- file.close()
- return code
- end
- rednet.open("top") -- Assuming the modem is on the top
- print("Webserver running...")
- while true do
- local senderID, message = rednet.receive()
- if message == "GET" then
- local code = loadWebsite()
- if code then
- rednet.send(senderID, code)
- else
- rednet.send(senderID, "Website not found.")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement