Mercurial Hosting > freedit
view src/tools/cookies.html.luan @ 17:a602a5735a37
set up test.freedit.org
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 07 Jul 2022 15:30:06 -0600 |
parents | 2f20b11affdd |
children |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local pairs = Luan.pairs or error() local Html = require "luan:Html.luan" local html_encode = Html.encode or error() local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local Logging = require "luan:logging/Logging.luan" local logger = Logging.logger "cookies.html" return function() local name = Http.request.parameters.name if name ~= nil then local value = Http.request.parameters.value local persistent = Http.request.parameters.persistent if #value == 0 then Http.response.remove_cookie(name) elseif persistent ~= nil then Http.response.set_persistent_cookie(name,value) else Http.response.set_cookie(name,value) end Http.response.send_redirect "cookies.html" return end Io.stdout = Http.response.text_writer() %> <!doctype html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> form { margin-bottom: 16px; } </style> </head> <body> <h2>Cookies Tool</h2> <% for name, value in pairs(Http.request.cookies) do name = html_encode(name) value = html_encode(value) %> <form> <input name=name value="<%=name%>" type=hidden> <%=name%> = <input name=value value="<%=value%>" size=100> <label><input type=checkbox name=persistent>persistent</label> </form> <% end %> <form> <input name=name> = <input name=value size=100> <label><input type=checkbox name=persistent>persistent</label> <input type=submit> </form> </body> </html> <% end