<commit_before>--
-- For use with Algernon / Lua
-- 
-- Project page: https://github.com/xyproto/algernon
-- Web page: http://algernon.roboticoverlords.org/
--

-- Set the headers
content("application/javascript")
setheader("Cache-Control", "no-cache")

-- Use a Redis list for the comments
comments = List("comments")

-- Handle requests
if method() == "POST" then
  -- Add the form data to the comment list, as JSON
  comments:add(JSON(formdata()))
else
  -- Combine all the JSON comments to a JSON document
  print("["..table.concat(comments:getall(), ",").."]")
end
<commit_msg>Use the JSON document for storing comments<commit_after>--
-- For use with Algernon / Lua
-- 
-- Project page: https://github.com/xyproto/algernon
-- Web page: http://algernon.roboticoverlords.org/
--

-- Set the headers
content("application/javascript")
setheader("Cache-Control", "no-cache")

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

-- Handle requests
if method() == "POST" then
  -- Add the form data table to the JSON document
  comments:add(ToJSON(formdata()))
else
  -- Return the contents of the JSON file
  print(tostring(comments))
end

{'fraction_non_alphanumeric': 0.14853195164075994, 'fraction_numerical': 0.0, 'mean_word_length': 3.730612244897959, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3888775', 'n_tokens_mistral': 360, 'n_tokens_neox': 353, 'n_words': 115}