Hi everyone,

I'm proposing to split out from the django.views.static.serve() view the 
functionality to serve a single static file.
The new view could be named serve_file(), would take request and fullpath 
as parameters and would serve the given file. The code would essentially be 
the second half of the current serve() view.
The serve() view could then be modified to use serve_file(), once the 
fullpath has been found and isdir() check is done.

My usecase:
I'm writing a single-page javascript app, using Django for backend logic 
and API. The client side consists of js/css assets and a single html file. 
I want that html file to be served by the Django app whenever a user makes 
a request to a url that doesn't match anything else (e.g. api urls). The 
javascript app does its own url routing, so if the user comes to  /foo/bar  
, the same html file is served and the javascript shows the right page to 
the user.
ATM I've created a fallback view that contains copy-paste code from serve() 
and has the fullpath variable hardcoded. The reason I like serve() is that 
it contains some useful logic, such as being able to respond with 304 (Not 
Modified) and setting some useful http headers.

I can take care of creating a patch if the idea sounds good.

Rivo

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/5d9f0449-2b46-4c50-81f5-3b2e43e16512%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to