From 0be901efd864c0e48c66e1ef01c1305896cc0c19 Mon Sep 17 00:00:00 2001 From: Denis Fedoseev Date: Wed, 13 Feb 2019 13:13:32 +0300 Subject: [PATCH] /s/ route to get shorten url from console --- shrlbe.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/shrlbe.pl b/shrlbe.pl index 6e35b30..ff5141d 100644 --- a/shrlbe.pl +++ b/shrlbe.pl @@ -18,6 +18,13 @@ get '/' => sub ($c) { $c->render(template => 'index', page_data => {}); }; +get '/s/*url' => sub ($c) { + my $url = normalize_source_url($c->param('url')); + my $shorten_path = write_url($url); + my $shorten_url = $SITE_NAME.$shorten_path; + $c->render(text => $shorten_url); +}; + post '/' => sub ($c) { my $url = normalize_source_url($c->param('url')); my $shorten_path = write_url($url);