~ubuntu-branches/ubuntu/maverick/gunicorn/maverick

« back to all changes in this revision

Viewing changes to examples/alt_spec.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-07-16 10:44:12 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100716104412-iddgoj0lss2hxg7q
Tags: 0.10.0-1
* New upstream release.
* Add python-setproctitle to Suggests. Thanks to Örjan Persson
  <orange@fobie.net>.
* Bump Standards-Version to 3.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -
 
2
#
 
3
# An example of how to pass information from the command line to
 
4
# a WSGI app. Only applies to the native WSGI workers used by
 
5
# Gunicorn sync (default) workers.
 
6
#
 
7
#   $ gunicorn 'alt_spec:load(arg)'
 
8
#
 
9
# Single quoting is generally necessary for shell escape semantics.
 
10
#
 
11
# This file is part of gunicorn released under the MIT license. 
 
12
# See the NOTICE for more information.
 
13
 
 
14
def load(arg):
 
15
    def app(environ, start_response):
 
16
        data = 'Hello, %s!\n' % arg
 
17
        status = '200 OK'
 
18
        response_headers = [
 
19
            ('Content-type','text/plain'),
 
20
            ('Content-Length', str(len(data)))
 
21
        ]
 
22
        start_response(status, response_headers)
 
23
        return iter([data])
 
24
    return app
 
25