A Web server in Twisted
Starting from this post that was triggered by this one I decided to do the same thing using Twisted Matrix.
Again the basic task is to write a webserver (the original poster was surprised in finding out how 'easy' it is to write a web server using .Net 2).
This is my solution:
from twisted.internet import reactor
from twisted.web2 import server, resource, channel, http
PORT = 8080
addSlash = True
def render(self, ctx):
<html><body><h1>This is the HTML body</h1></body></html>
s = server.Site(Page())
webbrowser.open("http://%s:%d" % ("localhost", PORT))
Easy isn't it?