58 lines
2.0 KiB
Python
58 lines
2.0 KiB
Python
"""
|
|
URL configuration for fraud_platform project.
|
|
"""
|
|
from django.contrib import admin
|
|
from django.contrib.sitemaps.views import sitemap
|
|
from django.urls import path, include
|
|
from django.conf import settings
|
|
from django.conf.urls.static import static
|
|
from django.http import HttpResponse, Http404
|
|
from django.views.decorators.cache import cache_control
|
|
from .sitemaps import sitemaps
|
|
import os
|
|
|
|
@cache_control(max_age=86400) # Cache for 1 day
|
|
def favicon_view(request):
|
|
"""Serve favicon.ico"""
|
|
favicon_path = os.path.join(settings.BASE_DIR, 'static', 'favicon.ico')
|
|
if os.path.exists(favicon_path):
|
|
with open(favicon_path, 'rb') as f:
|
|
return HttpResponse(f.read(), content_type='image/x-icon')
|
|
raise Http404("Favicon not found")
|
|
|
|
@cache_control(max_age=86400) # Cache for 1 day
|
|
def robots_txt(request):
|
|
"""Serve robots.txt"""
|
|
content = """User-agent: *
|
|
Allow: /
|
|
Disallow: /admin/
|
|
Disallow: /accounts/
|
|
Disallow: /moderation/
|
|
Disallow: /analytics/
|
|
Disallow: /osint/admin-dashboard/
|
|
Disallow: /api/
|
|
|
|
Sitemap: {}/sitemap.xml
|
|
""".format(request.build_absolute_uri('/').rstrip('/'))
|
|
return HttpResponse(content, content_type='text/plain')
|
|
|
|
urlpatterns = [
|
|
path('admin/', admin.site.urls),
|
|
path('accounts/', include('accounts.urls')),
|
|
path('osint/', include('osint.urls')),
|
|
path('moderation/', include('moderation.urls')),
|
|
path('analytics/', include('analytics.urls')),
|
|
path('legal/', include('legal.urls')),
|
|
path('', include('reports.urls')), # Home page and reports (reports:home, reports:list, etc.)
|
|
# SEO
|
|
path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'),
|
|
path('robots.txt', robots_txt, name='robots'),
|
|
# Favicon
|
|
path('favicon.ico', favicon_view, name='favicon'),
|
|
]
|
|
|
|
# Serve media files in development
|
|
if settings.DEBUG:
|
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
|
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|