/[RFID]/3m-810.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /3m-810.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 43 by dpavlin, Tue Jun 23 12:19:30 2009 UTC revision 44 by dpavlin, Tue Jun 23 13:10:18 2009 UTC
# Line 8  use Data::Dump qw/dump/; Line 8  use Data::Dump qw/dump/;
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    
# Line 84  sub http_server { Line 85  sub http_server {
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                          }                          }

Legend:
Removed from v.43  
changed lines
  Added in v.44

  ViewVC Help
Powered by ViewVC 1.1.26