summaryrefslogtreecommitdiff
path: root/paste/webkit/examples/EchoServlet.py
diff options
context:
space:
mode:
authorIan Bicking <ian@ianbicking.org>2005-08-22 23:29:31 +0000
committerIan Bicking <ian@ianbicking.org>2005-08-22 23:29:31 +0000
commit82d331036f311709b77a1e3a90a9b191c9e49c61 (patch)
tree2c91bcd0181be8babe4146c3f448429e4840f29f /paste/webkit/examples/EchoServlet.py
parent36d1c63f5e12f1dfd6d5187359093a96a2fd2de4 (diff)
downloadpaste-git-82d331036f311709b77a1e3a90a9b191c9e49c61.tar.gz
Moved webkit to separate project
Diffstat (limited to 'paste/webkit/examples/EchoServlet.py')
-rw-r--r--paste/webkit/examples/EchoServlet.py57
1 files changed, 0 insertions, 57 deletions
diff --git a/paste/webkit/examples/EchoServlet.py b/paste/webkit/examples/EchoServlet.py
deleted file mode 100644
index 6dc30c6..0000000
--- a/paste/webkit/examples/EchoServlet.py
+++ /dev/null
@@ -1,57 +0,0 @@
-r"""\
-Paste/WebKit application
-
-Does things as requested. Takes variables:
-
-header.header-name=value, like
- header.location=http://yahoo.com
-
-error=code, like
- error=301 (temporary redirect)
- error=assert (assertion error)
-
-environ=true,
- display all the environmental variables, like
- key=str(value)\n
-
-message=string
- display string
-"""
-
-# Special WSGI version of WebKit:
-from paste.webkit.wkservlet import Page
-from paste import httpexceptions
-
-class EchoServlet(Page):
-
- def writeHTML(self):
- req = self.request()
- headers = {}
- for key, value in req.fields().items():
- if key.startswith('header.'):
- name = key[len('header.'):]
- self.response().setHeader(name, value)
- # @@: I shouldn't have to do this:
- headers[name] = value
-
- error = req.field('error', None)
- if error and error != 'iter':
- if error == 'assert':
- assert 0, "I am asserting zero!"
- raise httpexceptions.get_exception(
- int(error), headers=headers)
-
- if req.field('environ', None):
- items = req.environ().items()
- items.sort()
- self.response().setHeader('content-type', 'text/plain')
- for name, value in items:
- self.write('%s=%s\n' % (name, value))
- return
-
- if req.hasField('message'):
- self.response().setHeader('content-type', 'text/plain')
- self.write(req.field('message'))
- return
-
- self.write('hello world!')