GithubHelp home page GithubHelp logo

realorangeone / django-simple-robots Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dabapps/django-simple-robots

0.0 2.0 0.0 28 KB

Simple robots.txt file serving for web applications

License: BSD 2-Clause "Simplified" License

Shell 4.76% Python 95.24%

django-simple-robots's Introduction

django-simple-robots

Build Status pypi release

Most web applications shouldn't be indexed by Google. This app just provides a view that serves a "deny all" robots.txt.

In some cases, you do want your app to be indexed - but only in your production environment (not any staging environments). For this case, you can set ROBOTS_ALLOW_HOST. If the incoming hostname matches this setting, an "allow all" robots.txt will be served. Otherwise, the "deny all" will be served.

Tested against Django 2.2, 3.2 and 4.0 on Python 3.6, 3.7, 3.8, 3.9 and 3.10

Installation

Install from PIP

pip install django-simple-robots

In your root urlconf, add an entry as follows:

from django.conf.urls import url
from simple_robots.views import serve_robots

urlpatterns = [
    path("robots.txt", serve_robots),
    # ..... other stuff
]

Then, add simple_robots to INSTALLED_APPS in your settings.py

Optionally, set ROBOTS_ALLOW_HOST settings variable.

ROBOTS_ALLOW_HOST = "myproductionurl.com"

That's it!

Customization

The allow and disallow template are stored at robots.txt and robots-disallow.txt respectively. You can override these in your projects templates directory to customize the responses.

Code of conduct

For guidelines regarding the code of conduct when contributing to this repository please review https://www.dabapps.com/open-source/code-of-conduct/

django-simple-robots's People

Contributors

j4mie avatar nvlaarhoven avatar realorangeone avatar timstimpson avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.