RafaelFonseca
Add Django Django_webapp project to HF space
e50f22e
Raw History Blame Contribute Delete
2.42 kB
# webapp/urls.py
from django.urls import path
from django.contrib.auth import views as auth_views # You might not need this import if you're using custom views
from django.conf import settings
from . import views
# clear dev startup --> enforces login after each start --->only for dev, not for production
# It's generally better to handle session clearing in a management command or migration,
# but for quick dev iteration, this can be used. However, be cautious.
# If you need this, ensure it's only active during development.
# from django.contrib.sessions.models import Session
# Session.objects.all().delete() # Uncomment with caution!
urlpatterns = [
path("debug-csrf/", views.debug_csrf, name="debug_csrf"),
# User authentication (assuming you have login_view, register_view, logout_view)
path('register/', views.register_view, name='register'),
path('login/', views.login_view, name='login'),
path('logout/', views.logout_view, name='logout'),
# Application pages
path('', views.landing_page, name='landing_page'), # This is the root URL for your app
path('train_model/', views.train_model, name='train_model'),
path('results/', views.results_view, name='results'),
path('test-model/', views.test_model, name='test_model'),
# Asynchronous training and API
# This pattern will be matched relative to the root URL because it's included
# in the project's urls.py without a prefix.
path("train/start/", views.start_training, name="start_training"),
path("train/<str:run_id>/", views.training_status, name="training_status"),
path("train/<str:run_id>/done/", views.training_done, name="training_done"),
path("api/train/<str:run_id>/progress/", views.training_progress, name="training_progress"),
# Add this if you intend to use the landing_page as a named URL elsewhere
# path('landing/', views.landing_page, name='landing_page'), # This might be redundant if '/' maps to landing_page
path('save-model/', views.save_model, name='save_model'),
path('models/delete/', views.delete_saved_model, name='delete_saved_model'),
path('models/edit/', views.edit_saved_model, name='edit_saved_model'),
]
# Static files handling is usually in the project's urls.py, but can be here too
if settings.DEBUG:
from django.conf.urls.static import static
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)