Skip to content

Instantly share code, notes, and snippets.

@derblub
Last active December 28, 2015 02:29
Show Gist options
  • Save derblub/7428659 to your computer and use it in GitHub Desktop.
Save derblub/7428659 to your computer and use it in GitHub Desktop.
Quick one-liner to serve a robots.txt file directly from your urls.py in Django.
##################################################################################
# SERVING robots.txt FILE - should be removed on production and handled by
# the webserver directly (no need for django here)
url(r'^robots\.txt$', lambda r: HttpResponse("User-agent: *\nDisallow: /", mimetype="text/plain")),
##################################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment