[ACCEPTED]-Embedded Web Server in Python?-embeddedwebserver
How minimalistic and for what purpose?
SimpleHTTPServer comes 3 free as part of the standard Python libraries.
If 2 you need more features, look into CherryPy or (at 1 the top end) Twisted.
I'm becoming a big fan of the newly released 6 circuits library. It's a component/event framework 5 that comes with a very nice set of packages 4 for creating web servers & apps. Here's 3 the simple web example from the site:
from circuits.lib.web import Server, Controller class HelloWorld(Controller): def index(self): return "Hello World!" server = Server(8000) server += HelloWorld() server.run()
Its 2 WSGI support is no more complicated than 1 that, either. Good stuff.
If you're doing a lot of concurrent stuff, you 1 might consider Kamaelia's HTTPServer.
I've found web.py pretty easy to use : http://webpy.org/
If you want to use something from the standard 23 library I would strongly recommend not using 22 SimpleHTTPServer, but instead using
wsgiref.simple_server. SimpleHTTPServer 21 is awkward and a rather nonsensical way 20 to implement a web application, and while 19 raw WSGI isn't terribly easy (but certainly 18 possible), you have the option to use any 17 WSGI-based framework on top of it. Also 16 if you use wsgiref you will have the option 15 to change to a server like CherryPy later 14 (note that the server in CherryPy can be 13 used separately from the rest of the framework, and 12 you only need one file for just the server). For 11 a "real" web application CherryPy 10 has several advantages over wsgiref, but 9 for a locally hosted application it's unlikely 8 any of them will matter.
If you are making 7 a desktop application you will need to launch 6 a separate thread for either wsgiref or 5 CherryPy. If that's fine, then a WSGI-based 4 server would probably be easiest. If you 3 don't want to launch a separate thread for 2 the server then you most likely need to 1 use Twisted.
See the WSGI reference implementation.
I made this one. It just enhances Python's SimpleHTTPServer a bit to let you define custom actions depending on the request.
More Related questions