Mostly working Bailador pastebin
This file contains 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
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