Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Web Server Code
- -- Function to handle incoming requests
- local function handleRequest()
- local modemSide = "top" -- Adjust according to your setup
- rednet.open(modemSide)
- print("Web Server running...")
- while true do
- local id, message = rednet.receive()
- if message then
- local filePath = "/web.code" .. message:gsub("/", "-") .. ".lua" -- Map URL path to file
- if fs.exists(filePath) then
- local file = fs.open(filePath, "r")
- local code = file.readAll()
- file.close()
- rednet.send(id, code)
- else
- rednet.send(id, "Error: Page not found.")
- end
- end
- end
- end
- handleRequest()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement