2011-01-03 21:40:52 +00:00
|
|
|
package base;
|
2011-01-03 22:18:06 +00:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
2011-01-03 21:40:52 +00:00
|
|
|
use nginx;
|
|
|
|
|
|
|
|
|
|
|
|
sub handler {
|
2011-01-03 22:18:06 +00:00
|
|
|
my $r = shift();
|
|
|
|
|
2011-01-03 21:40:52 +00:00
|
|
|
$r->send_http_header("text/plain");
|
2011-01-03 22:18:06 +00:00
|
|
|
return OK if $r->header_only();
|
2011-01-03 21:40:52 +00:00
|
|
|
|
2011-01-03 22:18:06 +00:00
|
|
|
$r->print("Hello There!\n");
|
|
|
|
$r->rflush();
|
2011-01-03 21:40:52 +00:00
|
|
|
|
|
|
|
if (-f $r->filename or -d _) {
|
|
|
|
$r->print($r->uri, " exists!\n");
|
2011-01-03 22:18:06 +00:00
|
|
|
} else {
|
|
|
|
$r->print($r->uri, " does not exist!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
my $directory = '/home/me/tmp';
|
|
|
|
# '/home/me/src/LearningPerl/src/web';
|
|
|
|
|
|
|
|
my $didopen = opendir(DIR, $directory);
|
|
|
|
if ($didopen) {
|
|
|
|
while (my $file = readdir(DIR)) {
|
|
|
|
$r->print("$file\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
closedir(DIR);
|
2011-01-03 21:40:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
1;
|
|
|
|
__END__
|