13 lines
391 B
Python
13 lines
391 B
Python
|
from django.views.generic import View
|
||
|
from django.http import JsonResponse
|
||
|
|
||
|
from .api import GoogleAPI
|
||
|
|
||
|
class PlacesAutocompleteView(View):
|
||
|
def get(self, request, *args, **kwargs):
|
||
|
if term := request.GET.get("term"):
|
||
|
api = GoogleAPI()
|
||
|
results = api.autocomplete(term)
|
||
|
else:
|
||
|
results = []
|
||
|
return JsonResponse(results, safe=False)
|