add connection test api view

This commit is contained in:
simon 2022-03-31 21:13:21 +07:00
parent 46622d9ab2
commit 9ab6955125
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 14 additions and 0 deletions

View File

@ -6,6 +6,7 @@ from api.views import (
DownloadApiListView,
DownloadApiView,
LoginApiView,
PingView,
PlaylistApiView,
VideoApiListView,
VideoApiView,
@ -14,6 +15,7 @@ from api.views import (
from django.urls import path
urlpatterns = [
path("ping/", PingView.as_view(), name="ping"),
path("login/", LoginApiView.as_view(), name="api-login"),
path(
"video/",

View File

@ -263,6 +263,18 @@ class DownloadApiListView(ApiBaseView):
return Response(data)
class PingView(ApiBaseView):
"""resolves to /api/ping/
GET: test your connection
"""
@staticmethod
def get(request):
"""get pong"""
data = {"pong": request.user.id}
return Response(data)
class LoginApiView(ObtainAuthToken):
"""resolves to /api/login/
POST: return token and username after successful login