Skip to content
Browse files

webpy and django examples now working

git-svn-id: http://evserver.googlecode.com/svn/trunk@77 e9bb6d7e-af12-11dd-bad7-87afd3b02348
  • Loading branch information...
1 parent 4fb49c9 commit 349574ffb1595e8e1c348b9f2886f5bc0f5fba00 majek04 committed Feb 5, 2009
View
7 evserver/examples/django_project/README
@@ -1,7 +1,6 @@
-to run this project try something like that, from the examples directory:
+To run this example simply run:
+python manage.py runevserver
+Other possibility is to try something like that:
DJANGO_SETTINGS_MODULE=django_project.settings PYTHONPATH=. evserver -l 127.0.0.1:8000 --framework=django
-http://127.0.0.1/
- simple clock example
-
View
16 evserver/examples/django_project/views.py
@@ -1,20 +1,16 @@
# Create your views here.
from django.http import HttpResponse
-import os
-import time
+import socket
import datetime
-# basic clock example
def django_clock(request):
- def iter():
- fd = os.open('/dev/null', os.O_RDONLY)
+ def iterator():
+ sd = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
while True:
- yield request.environ['x-wsgiorg.fdevent.readable'](fd, 1.0)
+ yield request.environ['x-wsgiorg.fdevent.readable'](sd, 1.0)
yield '%s\n' % (datetime.datetime.now(),)
except GeneratorExit:
pass
- os.close(fd)
- return HttpResponse(iter(), mimetype="text/plain")
-
-
+ sd.close()
+ return HttpResponse(iterator(), mimetype="text/plain")
View
12 evserver/examples/framework_webpy.py
@@ -2,7 +2,6 @@
# evserver --exec "import examples.framework_webpy; application = examples.framework_webpy.application"
#
import web
-import os
import datetime
import socket
@@ -23,13 +22,8 @@ def iterable():
except GeneratorExit:
pass
sd.close()
- web.ctx.output = iterable()
+ return iterable()
-# from http://code.google.com/p/modwsgi/wiki/IntegrationWithWebPy
-try:
- # webpy 0.3
- application = web.application(urls, globals()).wsgifunc()
-except AttributeError:
- # webpy 0.2
- application = web.wsgifunc(web.webpyfunc(urls, globals()))
+# webpy 0.3 specific
+application = web.application(urls, globals()).wsgifunc()

0 comments on commit 349574f

Please sign in to comment.
Something went wrong with that request. Please try again.