urls.py 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. from .admin import archivebox_admin
  2. from django.urls import path, include
  3. from django.views import static
  4. from django.contrib.staticfiles.urls import staticfiles_urlpatterns
  5. from django.conf import settings
  6. from django.views.generic.base import RedirectView
  7. from core.views import HomepageView, SnapshotView, PublicIndexView, AddView, HealthCheckView
  8. # print('DEBUG', settings.DEBUG)
  9. urlpatterns = [
  10. path('public/', PublicIndexView.as_view(), name='public-index'),
  11. path('robots.txt', static.serve, {'document_root': settings.STATICFILES_DIRS[0], 'path': 'robots.txt'}),
  12. path('favicon.ico', static.serve, {'document_root': settings.STATICFILES_DIRS[0], 'path': 'favicon.ico'}),
  13. path('docs/', RedirectView.as_view(url='https://github.com/ArchiveBox/ArchiveBox/wiki'), name='Docs'),
  14. path('archive/', RedirectView.as_view(url='/')),
  15. path('archive/<path:path>', SnapshotView.as_view(), name='Snapshot'),
  16. path('admin/core/snapshot/add/', RedirectView.as_view(url='/add/')),
  17. path('add/', AddView.as_view(), name='add'),
  18. path('accounts/login/', RedirectView.as_view(url='/admin/login/')),
  19. path('accounts/logout/', RedirectView.as_view(url='/admin/logout/')),
  20. path('accounts/', include('django.contrib.auth.urls')),
  21. path('admin/', archivebox_admin.urls),
  22. path('health/', HealthCheckView.as_view(), name='healthcheck'),
  23. path('error/', lambda _: 1/0),
  24. # path('jet_api/', include('jet_django.urls')), Enable to use https://www.jetadmin.io/integrations/django
  25. path('index.html', RedirectView.as_view(url='/')),
  26. path('index.json', static.serve, {'document_root': settings.OUTPUT_DIR, 'path': 'index.json'}),
  27. path('', HomepageView.as_view(), name='Home'),
  28. ]
  29. urlpatterns += staticfiles_urlpatterns()
  30. if settings.DEBUG_TOOLBAR:
  31. import debug_toolbar
  32. urlpatterns += [
  33. path('__debug__/', include(debug_toolbar.urls)),
  34. ]
  35. # # Proposed FUTURE URLs spec
  36. # path('', HomepageView)
  37. # path('/add', AddView)
  38. # path('/public', PublicIndexView)
  39. # path('/snapshot/:slug', SnapshotView)
  40. # path('/admin', admin.site.urls)
  41. # path('/accounts', django.contrib.auth.urls)
  42. # # Prposed REST API spec
  43. # # :slugs can be uuid, short_uuid, or any of the unique index_fields
  44. # path('api/v1/'),
  45. # path('api/v1/core/' [GET])
  46. # path('api/v1/core/snapshot/', [GET, POST, PUT]),
  47. # path('api/v1/core/snapshot/:slug', [GET, PATCH, DELETE]),
  48. # path('api/v1/core/archiveresult', [GET, POST, PUT]),
  49. # path('api/v1/core/archiveresult/:slug', [GET, PATCH, DELETE]),
  50. # path('api/v1/core/tag/', [GET, POST, PUT]),
  51. # path('api/v1/core/tag/:slug', [GET, PATCH, DELETE]),
  52. # path('api/v1/cli/', [GET])
  53. # path('api/v1/cli/{add,list,config,...}', [POST]), # pass query as kwargs directly to `run_subcommand` and return stdout, stderr, exitcode
  54. # path('api/v1/extractors/', [GET])
  55. # path('api/v1/extractors/:extractor/', [GET]),
  56. # path('api/v1/extractors/:extractor/:func', [GET, POST]), # pass query as args directly to chosen function
  57. # future, just an idea:
  58. # path('api/v1/scheduler/', [GET])
  59. # path('api/v1/scheduler/task/', [GET, POST, PUT]),
  60. # path('api/v1/scheduler/task/:slug', [GET, PATCH, DELETE]),