~ubuntu-branches/ubuntu/saucy/uwsgi/saucy

« back to all changes in this revision

Viewing changes to hello_world.py

  • Committer: Package Import Robot
  • Author(s): Janos Guljas
  • Date: 2012-04-30 17:35:22 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120430173522-qucwu1au3s9bflhb
Tags: 1.2+dfsg-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import uwsgi
2
 
import gevent
3
 
#uwsgi.cache_set('/', "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\nHello World from cache")
 
2
if uwsgi.loop == 'gevent':
 
3
    import gevent
 
4
 
 
5
print uwsgi.version
 
6
print uwsgi.workers()
 
7
try:
 
8
    uwsgi.cache_set('foo', "Hello World from cache")
 
9
except:
 
10
    pass
4
11
def application(env, start_response):
 
12
    if uwsgi.loop == 'gevent':
 
13
        gevent.sleep()
5
14
    start_response('200 OK', [('Content-Type', 'text/html')])
6
 
    yield "foobar"
7
 
    gevent.sleep(10)
 
15
    yield "foobar<br/>"
 
16
    if uwsgi.loop == 'gevent':
 
17
        gevent.sleep(3)
8
18
    yield str(env['wsgi.input'].fileno())
9
19
    yield "<h1>Hello World</h1>"
 
20
    try:
 
21
        yield uwsgi.cache_get('foo')
 
22
    except:
 
23
        pass