mirror of
https://github.com/wahyd4/links.git
synced 2026-08-09 05:06:16 +10:00
Fix api endpoints routes
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
from django.urls import path, include
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from . import page_views
|
||||
|
||||
router = DefaultRouter(trailing_slash=False)
|
||||
router.register('pages', page_views.PageViewSet, basename='api-pages')
|
||||
|
||||
urlpatterns = [
|
||||
path('', include(router.urls)),
|
||||
]
|
||||
@@ -4,5 +4,7 @@ from .models import Page
|
||||
class PageSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Page
|
||||
fields = ['id', 'url', 'title', 'summary', 'content', 'created_at', 'updated_at']
|
||||
read_only_fields = ['created_at', 'updated_at']
|
||||
fields = ['id', 'url', 'title', 'summary', 'content', 'screenshot_path',
|
||||
'process_status', 'created_at', 'updated_at']
|
||||
read_only_fields = ['id', 'screenshot_path', 'process_status',
|
||||
'created_at', 'updated_at']
|
||||
|
||||
+1
-11
@@ -1,12 +1,7 @@
|
||||
from django.urls import path, include
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from django.urls import re_path
|
||||
from . import views
|
||||
from . import page_views
|
||||
|
||||
router = DefaultRouter(trailing_slash=False)
|
||||
router.register(r'pages', views.PageViewSet, basename='api-page')
|
||||
|
||||
urlpatterns = [
|
||||
# Regular UI URLs
|
||||
path('', views.LinkListView.as_view(), name='link_list'),
|
||||
@@ -32,13 +27,8 @@ urlpatterns = [
|
||||
path('fetch-page-info/', page_views.fetch_page_info, name='fetch-page-info'),
|
||||
path('ui/screenshots/', page_views.ScreenshotGalleryView.as_view(), name='screenshot-gallery'),
|
||||
|
||||
# API URLs - place before catch-all alias routes
|
||||
path('api/', include(router.urls)),
|
||||
|
||||
# Aliases - these should always be last as they're catch-all routes
|
||||
# Aliases - these should always be last
|
||||
path('<str:alias>/', views.redirect_to_original, name='redirect_to_original'),
|
||||
path('<str:alias>/<str:param>/', views.redirect_to_original, name='redirect_to_original_with_param'),
|
||||
path('alias/<str:alias>/', views.LinkDetailView.as_view(), name='link_detail_by_alias'),
|
||||
|
||||
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user