BUSINESSTRACKER / urls.py
JOSHUAJEFFERSON's picture
Update urls.py
f6f452d verified
Raw History Blame Contribute Delete
1.34 kB
from django.contrib import admin
from django.urls import path, include
from django.http import HttpResponse
from django.contrib.auth import get_user_model
# Health check and Superuser Creator
def home_view(request):
User = get_user_model()
message = "<h1>Business Tracker Backend is Up!</h1>"
try:
if not User.objects.filter(email='joshuaolega193@gmail.com').exists():
User.objects.create_superuser('joshuaolega193@gmail.com', 'YourSecurePassword123!')
message += "<p style='color: green;'>Superuser 'joshuaolega193@gmail.com' created successfully!</p>"
else:
message += "<p>Superuser already exists.</p>"
except Exception as e:
message += f"<p style='color: red;'>Creation status: {e}</p>"
message += "<p>Try <a href='/admin/'>/admin/</a></p>"
return HttpResponse(message)
urlpatterns = [
path('', home_view),
path('admin/', admin.site.urls),
# CHANGED: Removed 'users/' so paths match frontend (e.g., /api/login/)
path('api/', include('users.urls')),
path('api/dashboard/', include('dashboard.urls')),
path('api/invoices/', include('invoices.urls')),
path('api/receipts/', include('receipts.urls')),
path('api/inventory/', include('inventory.urls')),
path('api/reports/', include('reports.urls')),
]