Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

28 lines (22 sloc) 0.613 kB
use Bailador; Bailador::import;
use DBIish;
my $db = DBIish.connect('SQLite', database => 'blog.db');
sub get-articles {
my $sth = $db.prepare: 'SELECT * FROM articles';
$sth.execute;
return $sth.fetchall_arrayref.map: {
{ title => $_[0],
pubdate => $_[1],
text => $_[2] }
};
}
get '/' => sub {
template 'index.tt', { articles => get-articles };
}
post '/post' => sub {
my $p = request.params;
my $sth = $db.prepare: 'INSERT INTO articles VALUES (?, datetime(?), ?)';
$sth.execute($p<title>, DateTime.now.posix, $p<text>);
"ok, done";
}
baile;
Jump to Line
Something went wrong with that request. Please try again.