ADD: Api endpoint for search suggestions
This commit is contained in:
parent
0ac29fd7d5
commit
468fb338f1
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,3 +2,4 @@ db.sqlite3
|
||||||
videos/
|
videos/
|
||||||
channel_archiver/yt-dlp-archive.txt
|
channel_archiver/yt-dlp-archive.txt
|
||||||
channel_archiver/UnusualVideos*
|
channel_archiver/UnusualVideos*
|
||||||
|
*__pycache__*
|
||||||
0
api/__init__.py
Normal file
0
api/__init__.py
Normal file
6
api/urls.py
Normal file
6
api/urls.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
from django.urls import path
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('', views.query)
|
||||||
|
]
|
||||||
10
api/views.py
Normal file
10
api/views.py
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
from rest_framework.response import Response
|
||||||
|
from rest_framework.decorators import api_view
|
||||||
|
from core.models import Video
|
||||||
|
from core.serializers import VideoSerializer
|
||||||
|
|
||||||
|
@api_view(['GET'])
|
||||||
|
def query(request):
|
||||||
|
videos = Video.objects.all()
|
||||||
|
serializer = VideoSerializer(videos, many=True)
|
||||||
|
return Response(serializer.data)
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
|
|
||||||
from .models import Video
|
from .models import Video
|
||||||
|
|
||||||
@admin.register(Video)
|
@admin.register(Video)
|
||||||
|
|
|
||||||
7
core/serializers.py
Normal file
7
core/serializers.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
from rest_framework import serializers
|
||||||
|
from .models import Video
|
||||||
|
|
||||||
|
class VideoSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Video
|
||||||
|
fields = ['id', 'name']
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.core, name='core'),
|
path('', views.core, name='core'),
|
||||||
path('status/', views.status, name='status'),
|
path('status/', views.status, name='status'),
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
'sage_stream',
|
#'sage_stream',
|
||||||
'core'
|
'core'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path('auth/', include('django.contrib.auth.urls')),
|
path('auth/', include('django.contrib.auth.urls')),
|
||||||
path('', include('core.urls')),
|
path('', include('core.urls')),
|
||||||
path('/', include('core.urls')),
|
#path('/', include('core.urls')),
|
||||||
path('status/', include('core.urls')),
|
#path('status/', include('core.urls')),
|
||||||
path('api/', include('sage_stream.api.urls')),
|
path('api/', include('api.urls')),
|
||||||
]
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user