Last active
February 11, 2021 07:09
-
-
Save mentix02/eb6014fc0404a29bb6dd5b7252ea6f94 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.views import View | |
from django.http import JsonResponse | |
from django.views.generic import TemplateView | |
from book.search import search | |
class IndexView(TemplateView): | |
template_name = 'index.html' | |
class SearchBookTitleAPIView(View): | |
@staticmethod | |
def get(request): | |
q: str = request.GET.get('q') | |
if not q: | |
return JsonResponse({'error': 'Query not provided.'}, status=400) | |
else: | |
return JsonResponse(search(q), safe=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment