Skip to content

Instantly share code, notes, and snippets.

@punytan
Created October 14, 2010 15:34
Show Gist options
  • Save punytan/626385 to your computer and use it in GitHub Desktop.
Save punytan/626385 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Plack;
use Plack::Request;
my $app = sub {
my $env = shift;
my $req = Plack::Request->new($env);
if (my $id = $req->param('id')) {
$id =~ s/[^a-zA-Z0-9]//g;
my $location = "http://yapcasia.org/2010/order/view/$id";
return [301, ['Location' => $location], ["Your ticket: $location"]];
} else {
my $html = q{
<!DOCTYPE html>
<html>
<head><title>Input your order ID</title></head>
<body>
<form action="/">
Your order ID<input name="id" type="text" />
<input type="submit" />
</form>
</body>
</html>
};
return [200, ['Content-Type' => 'text/html'], [$html]];
}
};
$app;
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment