Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created December 26, 2011 23:26
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save tadzik/1522280 to your computer and use it in GitHub Desktop.
Mostly working Bailador pastebin
use Bailador;
unless 'data'.IO ~~ :d {
mkdir 'data'
}
get '/' => sub {
q[
<form action='/new_paste' method='post'>
<textarea name='content' cols=50 rows=10></textarea><br />
<input type='submit' value='Paste it!' />
</form>
]
}
post '/new_paste' => sub {
my $t = time;
my $c = request.params<content>;
unless {
return "No empty pastes please";
}
my $fh = open "data/$t", :w;
$fh.print: $c;
$fh.close;
return "New paste available at paste/$t";
}
get /paste\/(.+)/ => sub ($tag) {
if "data/$tag".IO.f {
return slurp "data/$tag"
}
return '404'
}
baile;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment