/usr/share/doc/libplack-perl/examples/dot-psgi/twitter-stream.psgi is in libplack-perl 1.0039-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | use AnyEvent::Twitter::Stream;
use Encode;
my $app = sub {
my $env = shift;
my $keyword = $env->{PATH_INFO};
$keyword =~ s!^/!!;
my $cb = sub { };
# track keywords
my $guard = AnyEvent::Twitter::Stream->new(
username => $ENV{TWITTER_USERNAME},
password => $ENV{TWITTER_PASSWORD},
method => "filter",
track => $keyword || "twitter",
on_tweet => sub { $cb->(@_) },
);
return sub {
my $respond = shift;
my $w = $respond->([ 200, ['Content-Type' => 'text/plain'] ]);
$cb = sub {
my $tweet = shift;
$w->write(Encode::encode_utf8($tweet->{text}) . "\n");
};
};
};
|