Skip to content

Commit

Permalink
Use the JSON document for storing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
xyproto committed Jun 17, 2015
1 parent 1b3542d commit 5ed1252
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
content("application/javascript")
setheader("Cache-Control", "no-cache")

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

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

0 comments on commit 5ed1252

Please sign in to comment.