From 775c3d4725f629ac77adeea05c9bda6639a1f577 Mon Sep 17 00:00:00 2001 From: Madhur Prajapati Date: Thu, 5 Oct 2023 20:22:48 +0530 Subject: [PATCH 1/2] added robots.txt --- api/api/templates/robots.txt | 8 ++++++++ api/conf/urls/__init__.py | 8 ++++++++ api/conf/urls/openapi.py | 8 ++++++++ templates/robots.txt | 8 ++++++++ 4 files changed, 32 insertions(+) create mode 100644 api/api/templates/robots.txt create mode 100644 templates/robots.txt diff --git a/api/api/templates/robots.txt b/api/api/templates/robots.txt new file mode 100644 index 00000000000..61550ec2e52 --- /dev/null +++ b/api/api/templates/robots.txt @@ -0,0 +1,8 @@ +# Block API endpoints +User-agent: * +Disallow: /v1/images/ +Disallow: /v1/audio/ +Disallow: /v1/auth/ + +User-agent: GPTBot +Disallow: / \ No newline at end of file diff --git a/api/conf/urls/__init__.py b/api/conf/urls/__init__.py index 432bc5aa8f9..029d49fbbe8 100644 --- a/api/conf/urls/__init__.py +++ b/api/conf/urls/__init__.py @@ -9,6 +9,7 @@ from django.contrib import admin from django.urls import include, path from django.views.generic import RedirectView +from django.views.generic.base import TemplateView from rest_framework.routers import SimpleRouter from api.views.audio_views import AudioViewSet @@ -35,6 +36,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": diff --git a/api/conf/urls/openapi.py b/api/conf/urls/openapi.py index 812373e7120..8f66d6b1297 100644 --- a/api/conf/urls/openapi.py +++ b/api/conf/urls/openapi.py @@ -1,4 +1,5 @@ from django.urls import path +from django.views.generic.base import TemplateView from drf_spectacular.views import ( SpectacularAPIView, @@ -11,4 +12,11 @@ path("", SpectacularRedocView.as_view(url_name="schema"), name="root"), path("swagger/", SpectacularSwaggerView.as_view(url_name="schema"), name="swagger"), path("schema/", SpectacularAPIView.as_view(api_version="v1"), name="schema"), + path( + "robots.txt/", + TemplateView.as_view( + template_name="robots.txt", + content_type="text/plain", + ), + ), ] diff --git a/templates/robots.txt b/templates/robots.txt new file mode 100644 index 00000000000..61550ec2e52 --- /dev/null +++ b/templates/robots.txt @@ -0,0 +1,8 @@ +# Block API endpoints +User-agent: * +Disallow: /v1/images/ +Disallow: /v1/audio/ +Disallow: /v1/auth/ + +User-agent: GPTBot +Disallow: / \ No newline at end of file From 25a3102d0213b5a62e90ac732ff035114caa9bec Mon Sep 17 00:00:00 2001 From: Madhur Prajapati Date: Thu, 5 Oct 2023 21:18:41 +0530 Subject: [PATCH 2/2] added robots.txt file to the api templates --- api/api/templates/robots.txt | 2 +- api/conf/urls/openapi.py | 7 ------- templates/robots.txt | 8 -------- 3 files changed, 1 insertion(+), 16 deletions(-) delete mode 100644 templates/robots.txt diff --git a/api/api/templates/robots.txt b/api/api/templates/robots.txt index 61550ec2e52..811e0134451 100644 --- a/api/api/templates/robots.txt +++ b/api/api/templates/robots.txt @@ -5,4 +5,4 @@ Disallow: /v1/audio/ Disallow: /v1/auth/ User-agent: GPTBot -Disallow: / \ No newline at end of file +Disallow: / diff --git a/api/conf/urls/openapi.py b/api/conf/urls/openapi.py index 8f66d6b1297..ef9cbeeaf08 100644 --- a/api/conf/urls/openapi.py +++ b/api/conf/urls/openapi.py @@ -12,11 +12,4 @@ path("", SpectacularRedocView.as_view(url_name="schema"), name="root"), path("swagger/", SpectacularSwaggerView.as_view(url_name="schema"), name="swagger"), path("schema/", SpectacularAPIView.as_view(api_version="v1"), name="schema"), - path( - "robots.txt/", - TemplateView.as_view( - template_name="robots.txt", - content_type="text/plain", - ), - ), ] diff --git a/templates/robots.txt b/templates/robots.txt deleted file mode 100644 index 61550ec2e52..00000000000 --- a/templates/robots.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Block API endpoints -User-agent: * -Disallow: /v1/images/ -Disallow: /v1/audio/ -Disallow: /v1/auth/ - -User-agent: GPTBot -Disallow: / \ No newline at end of file