Skip to content

Commit 5ed1252

Browse files
committed
Use the JSON document for storing comments
1 parent 1b3542d commit 5ed1252

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

server.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
content("application/javascript")
1010
setheader("Cache-Control", "no-cache")
1111

12-
-- Use a Redis list for the comments
13-
comments = List("comments")
12+
-- Use a JSON file for the comments
13+
comments = JFile("comments.json")
1414

1515
-- Handle requests
1616
if method() == "POST" then
17-
-- Add the form data to the comment list, as JSON
18-
comments:add(JSON(formdata()))
17+
-- Add the form data table to the JSON document
18+
comments:add(ToJSON(formdata()))
1919
else
20-
-- Combine all the JSON comments to a JSON document
21-
print("["..table.concat(comments:getall(), ",").."]")
20+
-- Return the contents of the JSON file
21+
print(tostring(comments))
2222
end

0 commit comments

Comments
 (0)