-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
I have this server_api:
function read(page,vars)
u = vars.user
a = [[
term.setBackgroundColor(colors.white)
term.clear()
term.setCursorPos(1,1)
term.setBackgroundColor(colors.red)
term.clearLine()
print("")
term.clearLine()
print("")
term.clearLine()
term.setCursorPos(20,2)
term.setTextColor(colors.white)
term.write("Sertex Dev Space")
term.setCursorPos(2,5)
term.setBackgroundColor(colors.white)
term.setTextColor(colors.black)
term.write("User: ")
term.setTextColor(colors.red)
term.write("]]..u..[[")
term.setCursorPos(2,7)
term.write("<]]..u..[[> ")
--term.setCursorPos(1,9)
--while true do
--parallel.waitForAny(function()
--term.setCursorPos(5+]]..#u..[[,7)
--firewolf.query("dev.sertex.com/send",{user=]]..u..[[,text=read()})
--end,function()
t = textutils.unserialize(firewolf.query("dev.sertex.com/raw")) or {}
term.setCursorPos(1,9)
for i = 1,#t do
term.clearLine()
term.setTextColor(colors.red)
term.write(" <"..t[i].user.."> ")
term.setTextColor(colors.black)
print(t[i].text)
end
term.setCursorPos(]]..5+#u..[[,7)
p = read()
if not p == "" then
firewolf.query("dev.sertex.com/send",{text=p,user="]]..u..[["})
end
firewolf.redirect("dev.sertex.com/read?user=]]..u..[[")
]]
return a
end
function send(page,vars)
server.log("Query: "..page)
f = fs.open("/chat.log","r")
b = f.readAll()
server.log("Content: "..b)
c = textutils.unserialize(b)
f.close()
c[#c+1] = {user=vars.user,text=vars.text}
f = fs.open("/chat.log","w")
b = textutils.serialize(c)
server.log("New content: "..b)
f.write(b)
f.close()
return "firewolf.redirect(\"dev.sertex.com/read?user="..vars.user.."\")"
end
function raw(page,vars)
a = fs.open("/chat.log","r")
c = a.readAll()
a.close()
return c
end
server.handleRequest("raw",raw)
server.handleRequest("send",send)
server.handleRequest("read",read)I went to /read?user=manu and wrote a message. No new message on the page and no new lines on the log
Metadata
Metadata
Assignees
Labels
No labels