Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added ReverseHTTP Script for using Red Laser - iPhone App
- Loading branch information
JEEN
committed
Jan 18, 2010
1 parent
3fdddc0
commit 70ab3fa
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}); | ||
} | ||
} | ||
} |