public
Created

  • Download Gist
gistfile1.pl
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
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>
]]
];
}
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.