CGI-ExtDirect

 view release on metacpan or  search on metacpan

examples/p5httpd  view on Meta::CPAN

);

use constant PATH_SEPARATOR => WINDOWS ? ';' : ':';

initialise();
main_loop();
exit;

################################## Subroutines ###################

sub logerr($$);
sub logmsg($);
sub log_and_die($);
sub cat($$;$);    # forward declarations

sub initialise {
  $HOSTNAME = $ENV{HOSTNAME} || "localhost";
  $I_am_child = 0
    ; # Will be 1 in child after a fork(). Children wil just exit after finishing work.

  
  $PROGRAM_NAME =~ s#\\#/#g;
  ($p5httpd_homedir) = ( $PROGRAM_NAME =~ m#^(.*)/# );
  $p5httpd_homedir ||= cwd;    # last resort

examples/p5httpd  view on Meta::CPAN

    <hr>
    <p><I>p5httpd/$version server at $localname port $port</I></p>
    </body></html>
EOF
}

# cat "relative/path", "text/html", $method; writes the appropriate
# response headers to STDOUT. If $method == GET (which is the default)
# then the file is dumped on STDOUT as well.

sub cat($$;$) {
  my ( $file, $mimetype, $method ) = @_;
  $method = "GET" unless $method;
  my $fullpath = "$server_root$file";

  my ( undef, undef, undef, undef, undef, undef, undef, $length, undef, $mtime )
    = stat($fullpath);
  $mtime = gmtime $mtime;
  my ( $day, $mon, $dm, $tm, $yr ) =
    ( $mtime =~ m/(...) (...) (..) (..:..:..) (....)/ );



( run in 0.694 second using v1.01-cache-2.11-cpan-65fba6d93b7 )