advertisement

Article:
  Write a Webserver in 100 Lines of Code or Less
Subject:   Perl's version
Date:   2004-11-19 17:27:10
From:   merlyn
From the HTTP::Daemon manpage:

use HTTP::Daemon;
use HTTP::Status;


my $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' and $r->url->path eq "/xyzzy") {
# remember, this is *not* recommended practice :-)
$c->send_file_response("/etc/passwd");
}
else {
$c->send_error(RC_FORBIDDEN)
}
}
$c->close;
undef($c);
}


1 to 1 of 1
  1. Perl's version
    2004-11-19 17:36:48  NeuralizR [View]

1 to 1 of 1