Skip to content

Instantly share code, notes, and snippets.

@stevan
Created May 2, 2010 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevan/387207 to your computer and use it in GitHub Desktop.
Save stevan/387207 to your computer and use it in GitHub Desktop.
use Android;
my $a = Android->new();
use Plack::Runner;
use Plack::Request;
my $runner = Plack::Runner->new;
$runner->parse_options(qw[
--server HTTP::Server::PSGI
--port 8888
]);
$runner->run(sub {
my $env = shift;
my $req = Plack::Request->new( $env );
if ( my $phone_number = $req->param('phone_number') ) {
$a->callNumber( $phone_number );
return [
200,
[ 'Content-Type' => 'text/html' ],
[qq[
<html>
<head>
<title>Plack On Droid</title>
</head>
<body>
<p>Calling $phone_number ...</p>
</body>
</html>
]]
];
}
else {
return [
200,
[ 'Content-Type' => 'text/html' ],
[q[
<html>
<head>
<title>Plack On Droid</title>
</head>
<body>
<form>
Enter a phone number to call<br/>
<input type="text" name="phone_number" />
<input type="submit" value="Go" />
</form>
</body>
</html>
]]
];
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment