Skip to content

Instantly share code, notes, and snippets.

@talentlessguy
Created May 14, 2020 09:55
Show Gist options
  • Save talentlessguy/defd9995ececf4c9465455acd6181217 to your computer and use it in GitHub Desktop.
Save talentlessguy/defd9995ececf4c9465455acd6181217 to your computer and use it in GitHub Desktop.
Page view counter for KVDB
-- example KVdb script
-- HTML output
kvdb.header["content-type"] = "text/html"
-- read HTTP form variable and set key
if kvdb.var.slug then
local count = kvdb.get(kvdb.var.slug)
local action = kvdb.var.action
if action == "mutation" then
if count then
count = count + 1
else
count = 0
end
kvdb.set(kvdb.var.slug, count)
else
kvdb.say(count)
end
else
kvdb.say('View counter for <a href="https://v1rtl.site">v1rtl.site</a>')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment