Gotcha, so this is python:
import BaseHTTPServer
class HelloWorldServer( BaseHTTPServer.BaseHTTPRequestHandler ): def do_GET( self ): self.send_response( 200 ) self.send_header( "Content-type", "text/html" ) self.end_headers() self.wfile.write( "hello world" )
server = BaseHTTPServer.HTTPServer( ( '', 8080 ), HelloWorldServer )
while 1: try: server.handle_request() except: break
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* recommened practice:-)
$c->send_file_response("/etc/passwd");
}
else {
$c->send_error(RC_FORBIDDEN)
}
}
$c->close;
undef($c);
}
Re:From HTTP::Daemon's manpage (same thing)
inkdroid on 2004-03-05T16:53:30
Whew, thanks Merlyn. Pythonic episode over:)