[OT] minimalist web server

David Tweet davidtweet at gmail.com
Sat Dec 1 22:21:28 EST 2007


Running this in Python should create a server running on localhost
port 80 that only serves blank pages:

import SimpleHTTPServer
import SocketServer

class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
  def do_GET(self):
    print >> self.wfile, ""

server = SocketServer.TCPServer(("", 80), MyHandler)
server.serve_forever()

(also see http://effbot.org/librarybook/simplehttpserver.htm)

On Dec 1, 2007 7:02 PM, Daniel Fetchinson <fetchinson at googlemail.com> wrote:
> > > I'm looking for the most minimalist web server ever that does nothing
> > > else than return a fixed static page for every request. Regardless of
> > > what the request is, it just needs to be an HTTP request to port 80,
> > > the web server should return always the same html document. What would
> > > be the best choice for this? The goal is of course to minimize system
> > > resources in terms of memory, cpu, etc, etc.
> >
> > If you're running linux, maybe you want tux.
> >
> > publicfile isn't exactly what you describe, but its description might
> > be of some interest:
> >
> > http://cr.yp.to/publicfile.html
>
>
> Thanks, tux looks good, the only problem is that one needs to
> recompile the kernel which I really don't want to do (so yes, I'm on
> linux). Publicfile seems to "know" already too much.
>
> The reason I need this is that my current best strategy to avoid ads
> in web pages is putting all ad server names into /etc/hosts and stick
> my local ip number next to them (127.0.0.1) so every ad request goes
> to my machine. I run apache which has an empty page for 404 errors so
> I'll just see that blank page for every ad. Now I guess apache is a
> pretty heavy weight guy so I'm looking for a lightweight alternative.
> Lighttpd, nginx and company are all too complex and "know" too much. I
> even considered just putting netcat into an infinite loop but I'm
> afraid if there is a security hole in netcat I might be screwed.
>
> Maybe now that I outlined a little more why I need this others can
> come up with more suggestions.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
-David



More information about the Python-list mailing list