Skip to content

Commit

Permalink
Add syntax highlighting to readme code snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
RealOrangeOne committed Nov 25, 2022
1 parent 91d5b51 commit 50f8911
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,36 @@ Tested against Django 2.2, 3.2 and 4.0 on Python 3.6, 3.7, 3.8, 3.9 and 3.10

Install from PIP

pip install django-simple-robots
```bash
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
```python
from django.conf.urls import url
from simple_robots.views import serve_robots

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

Then, add `simple_robots` to `INSTALLED_APPS` in your `settings.py`.

Optionally, set `ROBOTS_ALLOW_HOSTS` settings variable.

ROBOTS_ALLOW_HOSTS = ["myproductionurl.com"]
```python
ROBOTS_ALLOW_HOSTS = ["myproductionurl.com"]
```

`ROBOTS_ALLOW_HOSTS` also supports multiple options, similar to [`ALLOWED_HOSTS`](https://docs.djangoproject.com/en/stable/ref/settings/#allowed-hosts):

# Allow all subdomains of `myproductionurl.com` (including the apex) and exactly `myotherproductionurl.com` (no subdomains)
ROBOTS_ALLOW_HOSTS = [".myproductionurl.com", "myotherproductionurl.com"]
```python
# Allow all subdomains of `myproductionurl.com` (including the apex) and exactly `myotherproductionurl.com` (no subdomains)
ROBOTS_ALLOW_HOSTS = [".myproductionurl.com", "myotherproductionurl.com"]
```

That's it!

Expand Down

0 comments on commit 50f8911

Please sign in to comment.