Mercurial Hosting > disearch
comparison src/add_server.js.luan @ 12:3e2cb946d511
form handling
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Mon, 30 Oct 2023 14:59:45 -0600 |
| parents | |
| children | af2b95854072 |
comparison
equal
deleted
inserted
replaced
| 11:62dd23f0b549 | 12:3e2cb946d511 |
|---|---|
| 1 local Luan = require "luan:Luan.luan" | |
| 2 local error = Luan.error | |
| 3 local String = require "luan:String.luan" | |
| 4 local regex = String.regex or error() | |
| 5 local Io = require "luan:Io.luan" | |
| 6 local Http = require "luan:http/Http.luan" | |
| 7 local Shared = require "site:/lib/Shared.luan" | |
| 8 local js_error = Shared.js_error or error() | |
| 9 local Logging = require "luan:logging/Logging.luan" | |
| 10 local logger = Logging.logger "add_server.js" | |
| 11 | |
| 12 | |
| 13 local invite_regex = regex[[^https://discord.gg/(\w+)$]] | |
| 14 | |
| 15 return function() | |
| 16 Io.stdout = Http.response.text_writer() | |
| 17 local parameters = Http.request.parameters | |
| 18 local id = parameters.id or error() | |
| 19 local name = parameters.name or error() | |
| 20 local icon = parameters.icon or error() | |
| 21 local invite = parameters.invite or error() | |
| 22 invite = invite_regex.match(invite) | |
| 23 logger.info("invite = "..invite) | |
| 24 if invite==nil then | |
| 25 js_error( "invite", [[Invalid Discord invite URL]] ) | |
| 26 return | |
| 27 end | |
| 28 %> | |
| 29 location = '/servers.html'; | |
| 30 <% | |
| 31 end |
