Skip to content

Commit

Permalink
added robots.txt for API endpoints (#3165)
Browse files Browse the repository at this point in the history
* added robots.txt for API endpoints

* added path for robots.txt for API endpoints

* Merge imports

---------

Co-authored-by: Dhruv Bhanushali <[email protected]>
  • Loading branch information
MysteryManav and dhruvkb authored Oct 10, 2023
1 parent b28665a commit 1487f91
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions api/api/templates/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Block API endpoints
User-agent: *
Disallow: /v1/images/
Disallow: /v1/audio/
Disallow: /v1/auth/

User-agent: GPTBot
Disallow: /
9 changes: 8 additions & 1 deletion api/conf/urls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
from django.views.generic import RedirectView
from django.views.generic import RedirectView, TemplateView
from rest_framework.routers import SimpleRouter

from api.views.audio_views import AudioViewSet
Expand All @@ -35,6 +35,13 @@
path("admin/", admin.site.urls),
path("healthcheck/", HealthCheck.as_view(), name="health"),
path("v1/", include(versioned_paths)),
path(
"robots.txt/",
TemplateView.as_view(
template_name="robots.txt",
content_type="text/plain",
),
),
]

if settings.ENVIRONMENT == "local":
Expand Down

0 comments on commit 1487f91

Please sign in to comment.