Login

Serving null files

Author:
ludvig.ericson
Posted:
February 27, 2007
Language:
Python
Version:
Pre .96
Tags:
null files views
Score:
0 (after 2 ratings)

Sometimes you have to serve null files. This quick hacky generic view lets you do that. The best example of that is robots.txt, I want my robots.txt to always be empty, at least for now.

The other example would be favicon.ico, but that's more often used to actually fill a purpose.

1
2
3
4
nullFile = lambda r: HttpResponse()

# As you might've figured out, you use it in urls.py with:
# (r'myRegex', 'some.module.nullFile'),

More like this

  1. Send large files through Django, and how to generate Zip files by jcrocholl 7 years, 6 months ago
  2. KMZMiddleware by giovabal 6 years, 10 months ago
  3. Updated FileField / ImageField with a delete checkbox by tomZ 6 years, 11 months ago
  4. X-Sendfile static file serve view by dokterbob 4 years, 4 months ago
  5. Serve static media and indexes from app directories [Python2.5, Development only] by adamlofts 6 years, 6 months ago

Comments

Please login first before commenting.