in reply to Webserver Oneliner

Please see Simple http server one-liner for some static files? (what a coincidence to get two so similar questions in such a short time... is this some sort of convention or race?)
Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^2: Webserver Oneliner
by alpha-lemming (Novice) on Oct 15, 2010 at 10:55 UTC
    The above link is helpful, thanks. Should have searched first :/
      The below code will trigger some ideas.

      HTTP::Daemon - http://search.cpan.org/~gaas/libwww-perl-5.837/lib/HTTP/Daemon.pm
      #!/usr/bin/perl use HTTP::Daemon; use HTTP::Status; my $d = HTTP::Daemon->new( LocalAddr => 'hostname', LocalPort => 8090, ); #$d = HTTP::Daemon->new || die; print "Please contact me at: <URL:", $d->url, ">\n"; while (my $c = $d->accept) { while (my $r = $c->get_request) { if ($r->method eq 'GET') { my $pathvar = $r->uri->path(); @exact_path = split("/",$pathvar); $c->send_file_response(@exact_path[1]); } else { $c->send_error(RC_FORBIDDEN) } } $c->close; undef($c); }
      Regards,
      Vivek