#!/storage/sdcard0/perl.5,21.10/bin/perl5.21.10 -w
use Mojolicious::Lite;
use lib 'perl-android/lib';
use Android;

get '/' => sub {
  my($c)= shift;
  $c->render(text => "Hello Android!");
};

get '/screen.png' => sub {
  my($c)= shift;
  my $fn='/sdcard/phone-screen.png';
  Android::screenshot($fn);
  open my $fh, '<', $fn or die;
  binmode $fh;
  local $/;
  my $screen = <$fh>;
  $c->render(data => $screen, format => 'png' );
};

get '/screen' => sub {
  my($c)= shift;

  $c->render(text  => <<HTML, format=> 'html');
<html>
<meta http-equiv="Refresh" content="5">
<body><img src="screen.png"></body>
</html>
HTML
  
};

app->start;
