1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/BaseHTTPRequestHandler/UnicodeApp.py Mon Aug 30 18:24:17 2004 +0000
1.3 @@ -0,0 +1,14 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +from WebStack.Adapters import BaseHTTPRequestHandler
1.7 +from Unicode import UnicodeResource
1.8 +import BaseHTTPServer
1.9 +
1.10 +# Special magic incantation.
1.11 +
1.12 +handler = BaseHTTPRequestHandler.HandlerFactory(UnicodeResource())
1.13 +address = ("", 8080)
1.14 +server = BaseHTTPServer.HTTPServer(address, handler)
1.15 +server.serve_forever()
1.16 +
1.17 +# vim: tabstop=4 expandtab shiftwidth=4
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/examples/Common/Unicode/__init__.py Mon Aug 30 18:24:17 2004 +0000
2.3 @@ -0,0 +1,41 @@
2.4 +#!/usr/bin/env python
2.5 +
2.6 +"A test of Unicode writing."
2.7 +
2.8 +import WebStack.Generic
2.9 +
2.10 +class UnicodeResource:
2.11 +
2.12 + "A Unicode test resource."
2.13 +
2.14 + def respond(self, trans):
2.15 + trans.set_content_type(WebStack.Generic.ContentType("text/html"))
2.16 +
2.17 + # Define a Unicode sequence.
2.18 +
2.19 + l = []
2.20 + for i in range(0, 4096, 64):
2.21 + l.append("<tr>")
2.22 + l.append("<th>%s</th>" % i)
2.23 + for j in range(i, i+64):
2.24 + l.append("<td>%s</td>" % unichr(j))
2.25 + l.append("<tr>\n")
2.26 + s = "".join(l)
2.27 +
2.28 + # Write the Unicode to the response.
2.29 +
2.30 + out = trans.get_response_stream()
2.31 + out.write("""
2.32 +<html>
2.33 + <head>
2.34 + <title>Unicode Example</title>
2.35 + </head>
2.36 + <body>
2.37 + <table>
2.38 + %s
2.39 + </table>
2.40 + </body>
2.41 +</html>
2.42 +""" % s)
2.43 +
2.44 +# vim: tabstop=4 expandtab shiftwidth=4
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/examples/Twisted/UnicodeApp.py Mon Aug 30 18:24:17 2004 +0000
3.3 @@ -0,0 +1,15 @@
3.4 +#!/usr/bin/env python
3.5 +
3.6 +from WebStack.Adapters import Twisted
3.7 +from Unicode import UnicodeResource
3.8 +import twisted.web.server
3.9 +import twisted.internet.reactor
3.10 +
3.11 +# Special magic incantation.
3.12 +
3.13 +top_level = Twisted.Dispatcher(UnicodeResource())
3.14 +site = twisted.web.server.Site(top_level)
3.15 +twisted.internet.reactor.listenTCP(8080, site)
3.16 +twisted.internet.reactor.run()
3.17 +
3.18 +# vim: tabstop=4 expandtab shiftwidth=4