# HG changeset patch # User paulb # Date 1093890257 0 # Node ID 239a52be1330c5b425e23e51b558850a8e629354 # Parent a451f549b73dd8c85cc846600ce1df3524ef6d04 [project @ 2004-08-30 18:24:13 by paulb] Added a Unicode example. diff -r a451f549b73d -r 239a52be1330 examples/BaseHTTPRequestHandler/UnicodeApp.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/BaseHTTPRequestHandler/UnicodeApp.py Mon Aug 30 18:24:17 2004 +0000 @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +from WebStack.Adapters import BaseHTTPRequestHandler +from Unicode import UnicodeResource +import BaseHTTPServer + +# Special magic incantation. + +handler = BaseHTTPRequestHandler.HandlerFactory(UnicodeResource()) +address = ("", 8080) +server = BaseHTTPServer.HTTPServer(address, handler) +server.serve_forever() + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r a451f549b73d -r 239a52be1330 examples/Common/Unicode/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/Common/Unicode/__init__.py Mon Aug 30 18:24:17 2004 +0000 @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +"A test of Unicode writing." + +import WebStack.Generic + +class UnicodeResource: + + "A Unicode test resource." + + def respond(self, trans): + trans.set_content_type(WebStack.Generic.ContentType("text/html")) + + # Define a Unicode sequence. + + l = [] + for i in range(0, 4096, 64): + l.append("") + l.append("%s" % i) + for j in range(i, i+64): + l.append("%s" % unichr(j)) + l.append("\n") + s = "".join(l) + + # Write the Unicode to the response. + + out = trans.get_response_stream() + out.write(""" + + + Unicode Example + + + + %s +
+ + +""" % s) + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r a451f549b73d -r 239a52be1330 examples/Twisted/UnicodeApp.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/Twisted/UnicodeApp.py Mon Aug 30 18:24:17 2004 +0000 @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +from WebStack.Adapters import Twisted +from Unicode import UnicodeResource +import twisted.web.server +import twisted.internet.reactor + +# Special magic incantation. + +top_level = Twisted.Dispatcher(UnicodeResource()) +site = twisted.web.server.Site(top_level) +twisted.internet.reactor.listenTCP(8080, site) +twisted.internet.reactor.run() + +# vim: tabstop=4 expandtab shiftwidth=4