Browse Source

Add path based versioning

pull/110/head
Hironsan 5 years ago
parent
commit
1c0411a3ce
3 changed files with 29 additions and 28 deletions
  1. 6
      app/app/urls.py
  2. 27
      app/server/api_urls.py
  3. 24
      app/server/urls.py

6
app/app/urls.py

@ -14,10 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.urls import path, include, re_path
from django.contrib.auth.views import PasswordResetView, LogoutView
from server.views import LoginView
from server.urls import router
urlpatterns = [
@ -28,6 +27,5 @@ urlpatterns = [
path('logout/', LogoutView.as_view(), name='logout'),
path('password_reset/', PasswordResetView.as_view(), name='password_reset'),
path('api-auth/', include('rest_framework.urls')),
path('api/', include(router.urls)),
re_path(r'^(?P<version>(v1))/', include('server.api_urls')),
]

27
app/server/api_urls.py

@ -0,0 +1,27 @@
from django.urls import path
from .api import ProjectList, ProjectDetail
from .api import LabelList, LabelDetail
from .api import DocumentList, DocumentDetail
from .api import EntityList, EntityDetail
from .api import StatisticsAPI
urlpatterns = [
path('projects', ProjectList.as_view(), name='project_list'),
path('projects/<int:project_id>', ProjectDetail.as_view(), name='project_detail'),
path('projects/<int:project_id>/statistics',
StatisticsAPI.as_view(), name='statistics'),
path('projects/<int:project_id>/labels',
LabelList.as_view(), name='label_list'),
path('projects/<int:project_id>/labels/<int:label_id>',
LabelDetail.as_view(), name='label_detail'),
path('projects/<int:project_id>/docs',
DocumentList.as_view(), name='doc_list'),
path('projects/<int:project_id>/docs/<int:doc_id>',
DocumentDetail.as_view(), name='doc_detail'),
path('projects/<int:project_id>/docs/<int:doc_id>/entities',
EntityList.as_view(), name='entity_list'),
path('projects/<int:project_id>/docs/<int:doc_id>/entities/<int:entity_id>',
EntityDetail.as_view(), name='entity_detail'),
]

24
app/server/urls.py

@ -1,37 +1,13 @@
from django.urls import path
from rest_framework import routers
from .views import IndexView
from .views import ProjectView, DatasetView, DataUpload, LabelView, StatsView, GuidelineView
from .views import ProjectsView, DataDownload, DataDownloadFile
from .views import DemoTextClassification, DemoNamedEntityRecognition, DemoTranslation
from .api import ProjectList, ProjectDetail
from .api import LabelList, LabelDetail
from .api import DocumentList, DocumentDetail
from .api import EntityList, EntityDetail
from .api import StatisticsAPI
router = routers.DefaultRouter()
urlpatterns = [
path('', IndexView.as_view(), name='index'),
path('api/projects/', ProjectList.as_view(), name='project_list'),
path('api/projects/<int:project_id>', ProjectDetail.as_view(), name='project_detail'),
path('api/projects/<int:project_id>/statistics/',
StatisticsAPI.as_view(), name='statistics'),
path('api/projects/<int:project_id>/labels/',
LabelList.as_view(), name='label_list'),
path('api/projects/<int:project_id>/labels/<int:label_id>/',
LabelDetail.as_view(), name='label_detail'),
path('api/projects/<int:project_id>/docs/',
DocumentList.as_view(), name='doc_list'),
path('api/projects/<int:project_id>/docs/<int:doc_id>/',
DocumentDetail.as_view(), name='doc_detail'),
path('api/projects/<int:project_id>/docs/<int:doc_id>/entities',
EntityList.as_view(), name='entity_list'),
path('api/projects/<int:project_id>/docs/<int:doc_id>/entities/<int:entity_id>/',
EntityDetail.as_view(), name='entity_detail'),
path('projects/', ProjectsView.as_view(), name='projects'),
path('projects/<int:project_id>/download',
DataDownload.as_view(), name='download'),

Loading…
Cancel
Save