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