Some routes

This commit is contained in:
swagg boi 2023-10-07 15:15:55 -04:00
parent d6e352faaa
commit 71ea81d18e
4 changed files with 24 additions and 4 deletions

View file

@ -14,4 +14,5 @@ A "useful" tool for turning hyperlinks into redirects in the name of shortening
## TODO ## TODO
1. Fix my `.emacs` to style stuff in a way that is not in fact insane 1. Process the form input
1. Make the return url gzip/base64'd

View file

@ -14,3 +14,14 @@ my $router = Router.new(root => '/');
$router.get(-> $request, $response { $router.get(-> $request, $response {
$response.html($templates.process: 'index'); $response.html($templates.process: 'index');
}); });
$router.post(-> $request, $response {
$response.html($templates.process: 'index');
});
# Try a wildcard to catch 'all' path
$router.get('/**', -> $request, $response {
my $url = $request.path.substr(1); # Omits the leading slash
$response.redirect($url);
});

View file

@ -4,3 +4,4 @@
<title>[% title %]</title> <title>[% title %]</title>
</head> </head>
<body> <body>
<h1>[% title %]</h1>

View file

@ -1,5 +1,12 @@
[% INCLUDE 'header' [% INCLUDE 'header'
title = 'Test page' %] title = 'Create new hyperlink' %]
<h1>Ayy...</h1> [% IF hyperlink %]
<p>lmao</p> <p>Your hyperlink is: <a href="[% hyperlink %]">[% hyperlink %]</a></p>
[% END %]
<form method="post">
<label for="hyperlink">Hyperlink</label>
<input id="hyperlink" name="hyperlink" type="text" minlength="4"
maxlength="2097152" required>
<button type="submit">Process</button>
</form>
[% INCLUDE 'footer' %] [% INCLUDE 'footer' %]