package base;

use strict;
use warnings;
use nginx;


sub handler {
    my $r = shift();

    $r->send_http_header("text/plain");
    return OK if $r->header_only();

    $r->print("Hello There!\n");
    $r->rflush();

    if (-f $r->filename or -d _) {
        $r->print($r->uri, " exists!\n");
    } 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);
    }
}


1;
__END__
