def test_app(request): return HttpResponse("Hello World!") def test_app2(request, name): return HttpResponse("Hello %s!" % name) def test_app3(request): return HttpResponse("wowa, meta") def test_app4(environ, start_response): start_response("200 OK", [("Content-type", "text/html")]) yield "i suck" urls = patterns( "", (r"^$", test_app), (r"^meta/$", django_view(wsgi_application(test_app3))), (r"^test4/$", django_view(test_app4)), (r"^(?P<name>.*?)/$", test_app2), ) application = wsgi_application(urls) ########NEW FILE########
from django.conf.urls.defaults import patterns from django.http import HttpResponse from django_wsgi import wsgi_application, django_view def test_app(request): return HttpResponse("Hello World!") def test_app2(request, name): return HttpResponse("Hello %s!" % name) def test_app3(request): return HttpResponse("wowa, meta") def test_app4(environ, start_response): start_response("200 OK", [("Content-type", "text/html")]) yield "i suck" urls = patterns("", (r"^$", test_app), (r"^meta/$", django_view(wsgi_application(test_app3))), (r"^test4/$", django_view(test_app4)), (r"^(?P<name>.*?)/$", test_app2), ) application = wsgi_application(urls)
FLICKR_PROFILE_URL = "http://www.flickr.com/photos/%s/" FLICKR_AVATAR_URL = "http://www.flickr.com/buddyicons/%s.jpg" def avatar(request, username): cache_key = "flickr:uid:%s" % username uid = cache.get(cache_key) if uid is None: page = urllib.urlopen(FLICKR_PROFILE_URL % username) if page.getcode() != 200: raise Http404 page = PyQuery(page.read()) uid = page.find("input[name=w]").val() cache.set(cache_key, uid) return HttpResponseRedirect(FLICKR_AVATAR_URL % uid) urlpatterns = patterns("", url(r"^$", "django.views.generic.simple.direct_to_template", {"template": "home.html"}), url(r"^i/(?P<username>.*?)\.jpg", avatar), ) if settings.DEBUG: urlpatterns += patterns("", url(r"^static/(?P<path>.*)$", "django.views.static.serve", {"document_root": os.path.join(os.path.dirname(__file__), "static")}) ) application = wsgi_application(urlpatterns)