Mercurial Hosting > disearch
view src/tools/cookies.html.luan @ 4:8896ffd7b152
start login
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 22 Oct 2023 23:53:59 -0600 |
parents | |
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