Api endpoint for video search with querying implemented
This commit is contained in:
parent
468fb338f1
commit
95d5aa6992
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,3 +3,4 @@ videos/
|
|||
channel_archiver/yt-dlp-archive.txt
|
||||
channel_archiver/UnusualVideos*
|
||||
*__pycache__*
|
||||
*.pyc
|
||||
|
|
@ -2,5 +2,5 @@ from django.urls import path
|
|||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.query)
|
||||
path('', views.videoAPI),
|
||||
]
|
||||
|
|
@ -2,9 +2,11 @@ from rest_framework.response import Response
|
|||
from rest_framework.decorators import api_view
|
||||
from core.models import Video
|
||||
from core.serializers import VideoSerializer
|
||||
from django.db.models import Q
|
||||
|
||||
@api_view(['GET'])
|
||||
def query(request):
|
||||
videos = Video.objects.all()
|
||||
def videoAPI(request):
|
||||
q = request.GET.get('q', '')
|
||||
videos = Video.objects.filter(Q(id__contains=q) | Q(name__contains=q))
|
||||
serializer = VideoSerializer(videos, many=True)
|
||||
return Response(serializer.data)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user