Skip to content

Instantly share code, notes, and snippets.

@kaustumbh7
Created June 20, 2019 17:31
Show Gist options
  • Save kaustumbh7/8be040e5c57b62fd50c4c94b4e643e35 to your computer and use it in GitHub Desktop.
Save kaustumbh7/8be040e5c57b62fd50c4c94b4e643e35 to your computer and use it in GitHub Desktop.
from django.shortcuts import render
from .apps import WebappConfig
# Create your views here.
from django.http import HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from .apps import WebappConfig
class call_model(APIView):
def get(self,request):
if request.method == 'GET':
# sentence is the query we want to get the prediction for
params = request.GET.get('sentence')
# predict method used to get the prediction
response = WebappConfig.predictor.predict(sentence)
# returning JSON response
return JsonResponse(response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment