Serve a binary/static file from view callable (with paste.fileapp?)

89 views
Skip to first unread message

Jasper

unread,
Sep 20, 2011, 9:12:47 AM9/20/11
to pylons-discuss
Hi everyone,

I'd like to serve a (sometimes larger) binary file from one of my
views. It seems the preferred method of doing this is with
paste.fileapp.FileApp:

http://stackoverflow.com/questions/2413707/stream-a-file-to-the-http-response-in-pylons

(see last response)

docs: http://pythonpaste.org/modules/fileapp.html

However, the code example is for pylons, and I don't think
"self.start_response" has any meaning in a pyramid view callable,
right? If so, I don't know what it means.

So,

1) do you indeed think this is the best way to deal with possibly
larger (non-text) files?

2) how should i use it in a pyramids view?

Thanks!

Gael Pasgrimaud

unread,
Sep 20, 2011, 9:42:53 AM9/20/11
to pylons-...@googlegroups.com
Hi,

No, the best way is to use a real webserver like nginx with the
xsendfile module: http://wiki.nginx.org/XSendfile

>
> 2) how should i use it in a pyramids view?
>

this should work:

def file_view(request):
return request.get_response(FileApp(filename))

>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
> To post to this group, send email to pylons-...@googlegroups.com.
> To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
>
>

Jasper van den Bosch

unread,
Sep 20, 2011, 4:22:44 PM9/20/11
to pylons-...@googlegroups.com
Thanks!
Reply all
Reply to author
Forward
0 new messages