Skip to content

Commit

Permalink
added ReverseHTTP Script for using Red Laser - iPhone App
Browse files Browse the repository at this point in the history
  • Loading branch information
JEEN committed Jan 18, 2010
1 parent 3fdddc0 commit 70ab3fa
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions bin/ptth.pl
@@ -0,0 +1,31 @@
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
use AnyEvent::ReverseHTTP;
use DL2::Controller;
use Data::Dumper;
my $name = $ARGV[0];

my $guard = AnyEvent::ReverseHTTP->new(
label => $name,
token => '-',
on_request => \&handle_request,
)->connect;

AnyEvent->condvar->recv;

sub handle_request {
my $req = shift;

my $uri = $req->uri;
my ($code) = $uri =~ /q=(.+)$/;

if ($code) {
my $res = DL2::Controller->new({ keyword => $code });
$res->update;
if (!$res->is_error) {
printf("%s => %s\n", $code, $res->get_item->{title});
}
}
}

0 comments on commit 70ab3fa

Please sign in to comment.