Without much ado, here's the code that does the same, in about half as many lines of code:
import os
import BaseHTTPServer
class SimplestWebHandler(
BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.end_headers()
self.wfile.write('Hello, you requested '
+ self.path)
def main():
server = BaseHTTPServer.HTTPServer(('', 8000),
SimplestWebHandler)
print 'Server is looping.'
server.serve_forever()
if __name__ == '__main__':
main()
3 comments:
you can write even a smaller one using xinetd, even with xinetd code :)
If that's considered "writing a web server", so does this:
/etc/init.d/apache start
Note that mine is much more feature rich :)
Is this the Google App Engine?
Post a Comment