Skip to content

Instantly share code, notes, and snippets.

@szabgab
Created May 29, 2017 20:12
Show Gist options
  • Select an option

  • Save szabgab/512ca35028de45267ea130c9d5d87b91 to your computer and use it in GitHub Desktop.

Select an option

Save szabgab/512ca35028de45267ea130c9d5d87b91 to your computer and use it in GitHub Desktop.
static bailador
# this is planned to be a bit more generic than needed here
my $root = $*PROGRAM.absolute.IO.dirname;
if $root.IO.basename eq 'bin' {
$root = $root.IO.dirname;
}
my $files = Bailador::Route::StaticFile.new: directory => $root, path => /.*/;
get '/(.*)' => sub ($url) {
#return $root;
my $file = ($url eq '' ?? 'index' !! $url) ~ '.html';
#return $file;
my $path = $root.IO.child('views').child($file).Str;
if $path.IO.e {
return template($file)
}
# return False if $url eq '';
# my $static = $root.IO.child('public').child($url);
# content_type('text/css') if $url ~~ /\.css$/;
# content_type('image/x-icon') if $url ~~ /\.ico$/;
# return $static if $static.f;
return False;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment