Skip to content

Commit

Permalink
Add the beginnings of an API, plus an API endpoint to display a speci…
Browse files Browse the repository at this point in the history
…fic slide
  • Loading branch information
sheepman4267 committed Apr 15, 2024
1 parent 7b6c9a2 commit 6948e4b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions OpenShow/OpenShow/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from ninja import NinjaAPI

api = NinjaAPI()

api.add_router("/slides/", "slides.api.router")
2 changes: 2 additions & 0 deletions OpenShow/OpenShow/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from .api import api

urlpatterns = [
path('', include('core.urls')),
path('admin/', admin.site.urls),
path('api/', api.urls),
path('slides/', include('slides.urls')),
path('uubloomington/', include('uubloomington_api_connector.urls')),
path('pjlink/', include('pjlink_integration.urls')),
Expand Down
12 changes: 12 additions & 0 deletions OpenShow/slides/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from ninja import Router
from .models import Slide, Show
from django.shortcuts import get_object_or_404

router = Router()


@router.post("show_slide")
def show_slide(request, slide_pk, show_pk):
slide = get_object_or_404(Slide, pk=slide_pk)
show = get_object_or_404(Show, pk=show_pk)
slide.send_to_display(show.displays.all(), show=show)
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ django-feather
pypjlink
gunicorn
uvicorn
django-environ
django-environ
django-ninja

0 comments on commit 6948e4b

Please sign in to comment.