8 |
use Carp qw/confess/; |
use Carp qw/confess/; |
9 |
use Getopt::Long; |
use Getopt::Long; |
10 |
use File::Slurp; |
use File::Slurp; |
11 |
|
use JSON; |
12 |
|
|
13 |
use IO::Socket::INET; |
use IO::Socket::INET; |
14 |
|
|
85 |
if ( my $path = static( $client,$1 ) ) { |
if ( my $path = static( $client,$1 ) ) { |
86 |
warn ">> $path"; |
warn ">> $path"; |
87 |
} elsif ( $method =~ m{/scan} ) { |
} elsif ( $method =~ m{/scan} ) { |
88 |
print $client "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\n"; |
my $callback = $1 if $method =~ m{\?callback=([^&;]+)}; |
89 |
my $tags = scan_for_tags(); |
my $tags = scan_for_tags(); |
|
print $client "tags: ",dump($tags); |
|
90 |
my $json; |
my $json; |
91 |
map { $json->{$_} = decode_tag($_) } keys %$tags; |
map { |
92 |
print $client "decoded: ",dump( $json ); |
my $d = decode_tag($_); |
93 |
|
$d->{sid} = $_; |
94 |
|
push @{ $json->{tags} }, $d; |
95 |
|
} keys %$tags; |
96 |
|
print $client "HTTP/1.0 200 OK\r\nContent-Type: application/x-javascript\r\n\r\n$callback(", to_json($json), ")\r\n"; |
97 |
} else { |
} else { |
98 |
print $client "HTTP/1.0 404 Unkown method\r\n"; |
print $client "HTTP/1.0 404 Unkown method\r\n"; |
99 |
} |
} |
146 |
'stopbits=i' => \$stopbits, |
'stopbits=i' => \$stopbits, |
147 |
'handshake=s' => \$handshake, |
'handshake=s' => \$handshake, |
148 |
'meteor=s' => \$meteor_server, |
'meteor=s' => \$meteor_server, |
149 |
|
'http-server!' => \$http_server, |
150 |
) or die $!; |
) or die $!; |
151 |
|
|
152 |
my $verbose = $debug > 0 ? $debug-- : 0; |
my $verbose = $debug > 0 ? $debug-- : 0; |