From 485ac718ae64ca20c3ce171b88f9e549003dc859 Mon Sep 17 00:00:00 2001 From: Nikolay Zhuravlev Date: Sat, 30 Mar 2024 11:50:10 +0100 Subject: [PATCH] Add robots.txt --- anytask/index/views.py | 8 ++++++++ anytask/urls.py | 1 + 2 files changed, 9 insertions(+) diff --git a/anytask/index/views.py b/anytask/index/views.py index e392c8cd6..65a59fbaf 100644 --- a/anytask/index/views.py +++ b/anytask/index/views.py @@ -1,6 +1,10 @@ from django.shortcuts import render from schools.models import School +ROBOTS_TXT = """User-agent: * +Allow: / +Clean-param: next /accounts/login/ +""" def index(request): schools = School.objects.all().filter(is_active=True).order_by('name') @@ -24,3 +28,7 @@ def archive_index(request): } return render(request, 'archived_schools_page.html', context) + + +def robotstxt_view(request): + return HttpResponse(ROBOTS_TXT, content_type="text/plain") diff --git a/anytask/urls.py b/anytask/urls.py index b3165ee92..af0400071 100644 --- a/anytask/urls.py +++ b/anytask/urls.py @@ -46,4 +46,5 @@ url(r'^jupyter/', include('jupyter.urls')), url(r'^set_lang/', set_lang_view, name='set_lang'), url(r'^get_lang/', get_lang_view, name='get_lang'), + url(r'^$', index.views.index, name="index.views.robotstxt_view"), ]