from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings
from rest_framework.authtoken.views import obtain_auth_token

from api.urls import router
from api import views as api_views
from webapp import views

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', views.IndexRedirectView.as_view(), name='redirect_to_index'),
    path('articles/', include('webapp.urls')),
    path('accounts/', include('accounts.urls')),
    path('api/', include(router.urls)),
    path('api/login/', obtain_auth_token, name='api_token_auth'),
    path('api/logout/', api_views.LogoutAPIView.as_view(), name='api_logout'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
