[Chicago] help from Django and Pylons developers

Cosmin Stejerean cstejerean at gmail.com
Mon Apr 28 22:41:33 CEST 2008

On Mon, Apr 28, 2008 at 2:55 PM, Massimo Di Pierro
<mdipierro at cs.depaul.edu> wrote:
> Sorry the web2py way is better. Here is the complete code
>  #in applications/security/controller/default.py
>  class Jammer():
>   def read(self,n):  return 'x'*n
>  def jam():  return response.stream(Jammer())
>  in #routes.py
>  routes_in=(('.*(php|PHP|asp|ASP|jsp|JSP)','/security/default/jam'),)
>  and it does not matter which web server you use.
>  Massimo

What about web2py is better? I was commenting on a way to serve really
large files using the performance benefits of something like Apache or
Nginx (for static files) while still being able to use authentication
or dynamic generation of the file in Python. Your example just show
how to send an infinite stream of data to the client. This isn't hard
to do in Django either.

# in your views.py or somewhere else

class Jammer(object):
  def __iter__(self):
    while True:
      yield 'x'

def jam(request):
  return HttpResponse(Jammer())

#in your urlconf you can put something like
('(php|PHP|asp|ASP|jsp|JSP)/$', jam),

Cosmin Stejerean

More information about the Chicago mailing list