Created
October 14, 2010 15:34
-
-
Save punytan/626385 to your computer and use it in GitHub Desktop.
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 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