-
-
Save adamtaylor/5506085 to your computer and use it in GitHub Desktop.
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
#!perl | |
use Dancer; | |
use LWP::UserAgent; | |
get '/' => sub { | |
return <<EOF; | |
<html> | |
<head> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> | |
<script type="text/javascript"> | |
setInterval(function (){ | |
\$.get('tag', function(data) { | |
\$('#rfid').val(data); | |
//alert('Load was performed.'+data); | |
}) | |
},5000); | |
</script> | |
<title>RFID Sample Scanner</tile> | |
</head> | |
<body> | |
<h1>Sample Check-in</h1> | |
<form action="/check-in" method="post"> | |
RFID: <input type="text" name="rfid" id="rfid"/> <br /> | |
PID: <input type="pid" name="pid" /> <br /> | |
Location: <input type="location" name="location" /> <br /> | |
Size: <input type="size" name="size" /> <br /> | |
<input type="submit" value="» Check-in" /> | |
</form> | |
</body> | |
</html> | |
EOF | |
}; | |
get '/tag' => sub { | |
#my @out = `nfc-list`; | |
my @out; | |
my $rfid; | |
foreach my $line ( @out ) { | |
if ( $line =~ /UID/ ) { | |
$rfid = $line; | |
$rfid =~ s/UID\s+\(.+\)://; | |
$rfid =~ s/\s+//g; | |
} | |
} | |
if ( int(rand(10)) >= 5 ) { | |
$rfid = int(rand(10000)); | |
}; | |
return $rfid; | |
}; | |
post '/check-in' => sub { | |
my $pid = param('pid'); | |
my $rfid = param('rfid'); | |
my $location = param('location'); | |
my $size = param('size'); | |
my $ua = LWP::UserAgent->new(); | |
}; | |
dance; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment