X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=blobdiff_plain;f=examples%2Fpython%2Fwsgidir%2Findex.wsgi;fp=examples%2Fpython%2Fwsgidir%2Findex.wsgi;h=166241c5eefa38254c75b5640a4cd113551af4df;hp=0000000000000000000000000000000000000000;hb=8774cda21dfafd73df99686ded102c4f6f5e2d2e;hpb=84a034e1e63195a8378acacb35eae8e45ef78f0f diff --git a/examples/python/wsgidir/index.wsgi b/examples/python/wsgidir/index.wsgi new file mode 100644 index 0000000..166241c --- /dev/null +++ b/examples/python/wsgidir/index.wsgi @@ -0,0 +1,29 @@ +import sys, ashd.wsgiutil + +n = 0 + +def application(env, startreq): + global n + startreq("200 OK", [("Content-Type", "text/html")]) + yield "\n" + yield "Hello world from Python!\n" + yield "\n" + yield "

Hello world from Python/WSGI!

\n" + yield "

Do note how the single-process nature of ashd-wsgi " + yield "allows data to be kept in memory persistently across requests, and " + yield "how the following counter increases by one for each request: " + str(n) + "

\n" + n += 1 + yield "

This script is a very raw WSGI example, using no glue code " + yield "whatever, but you should be able to use whatever WSGI middleware " + yield "you like in order to make it easier to code WSGI. If you have no " + yield "particular preference, I might recommend " + yield "WRW, " + yield "my WSGI Request Wrapper library, which is particularly made for " + yield "ashd-wsgi and therefore, for instance, allows " + yield "non-pickleble objects (like sockets) to be stored in sessions.

" + yield "

If you have installed the Python3 utilities as well, there is " + yield "also a Python3 script to demonstrate that " + yield "Python3 is supported as well.\n" + yield "

The current Python interpreter is " + ashd.wsgiutil.htmlquote(sys.version) + ".

" + yield "\n" + yield "\n"