Created
May 29, 2017 20:12
-
-
Save szabgab/512ca35028de45267ea130c9d5d87b91 to your computer and use it in GitHub Desktop.
static bailador
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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