add bookshelf

This commit is contained in:
2023-01-25 01:10:36 +00:00
parent 6c5dabec65
commit d73a8fcffa
9 changed files with 93 additions and 1 deletions

15
bookshelf/bookshelf.raku Normal file
View File

@@ -0,0 +1,15 @@
use v6.d;
use Humming-Bird::Core;
use Template::Mustache;
my constant $BOOKSHELF-LOCATION = 'bookshelf.txt';
my $tmpl = Template::Mustache.new: :from<.>;
get('/bookshelf', -> $request, $response {
my @books = $BOOKSHELF-LOCATION.IO.lines>>.split('^').map(-> ($name, $author, $href, $rating) { %(:$name, :$author, :$href, :$rating) });
$response.html($tmpl.render('bookshelf', { :@books }));
});
listen(8888);