Some routes
This commit is contained in:
parent
d6e352faaa
commit
71ea81d18e
|
@ -14,4 +14,5 @@ A "useful" tool for turning hyperlinks into redirects in the name of shortening
|
|||
|
||||
## 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
|
||||
|
|
|
@ -14,3 +14,14 @@ my $router = Router.new(root => '/');
|
|||
$router.get(-> $request, $response {
|
||||
$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);
|
||||
});
|
||||
|
|
|
@ -4,3 +4,4 @@
|
|||
<title>[% title %]</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>[% title %]</h1>
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
[% INCLUDE 'header'
|
||||
title = 'Test page' %]
|
||||
<h1>Ayy...</h1>
|
||||
<p>lmao</p>
|
||||
title = 'Create new hyperlink' %]
|
||||
[% IF hyperlink %]
|
||||
<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' %]
|
||||
|
|
Loading…
Reference in a new issue