""" URL configuration for expense_tracker project. The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/5.2/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin from django.urls import path, include, re_path from django.http import JsonResponse from django.views.generic import TemplateView from django.conf import settings from django.conf.urls.static import static from django.views.static import serve def root_view(request): return JsonResponse({"message": "Expense Tracker API is running", "endpoints": ["/api/auth/", "/api/finance/"]}) # Serve index.html for React app class ReactAppView(TemplateView): template_name = 'index.html' urlpatterns = [ path('api/', root_view), path('admin/', admin.site.urls), path('api/auth/', include('users.urls')), path('api/finance/', include('finance.urls')), path('api/analytics/', include('analytics.urls')), path('api/chat/', include('chatbot.urls')), ] # Serve static files (both in development and production with whitenoise) urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) # Serve assets directly from /assets/ (Vite builds with this path) urlpatterns += [ re_path(r'^assets/(?P.*)$', serve, {'document_root': settings.STATIC_ROOT / 'assets'}), re_path(r'^vite\.svg$', serve, {'document_root': settings.STATIC_ROOT, 'path': 'vite.svg'}), ] # Catch-all pattern for React Router - must be last # This will match any URL that doesn't start with /api/, /static/, or /assets/ urlpatterns += [ re_path(r'^(?!api/|static/|assets/|admin).*$', ReactAppView.as_view(), name='react-app'), ]