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/
|
||||
channel_archiver/yt-dlp-archive.txt
|
||||
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 .models import 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,11 +1,10 @@
|
|||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.core, name='core'),
|
||||
path('status/', views.status, name='status'),
|
||||
path('about/', views.about, name='about'),
|
||||
path('random/', views.random, name='random'),
|
||||
path('view/<int:id>', views.view, name='view'),
|
||||
]
|
||||
]
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ INSTALLED_APPS = [
|
|||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'rest_framework',
|
||||
'sage_stream',
|
||||
#'sage_stream',
|
||||
'core'
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ urlpatterns = [
|
|||
path('admin/', admin.site.urls),
|
||||
path('auth/', include('django.contrib.auth.urls')),
|
||||
path('', include('core.urls')),
|
||||
path('/', include('core.urls')),
|
||||
path('status/', include('core.urls')),
|
||||
path('api/', include('sage_stream.api.urls')),
|
||||
#path('/', include('core.urls')),
|
||||
#path('status/', include('core.urls')),
|
||||
path('api/', include('api.urls')),
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user