I am using django rest framework to take two string from URL and output as a json response.
below is the code I have tried and the response I got.
Input URL: http://127.0.0.1:8000/predict/?solute=CC(C)(C)Br&solvent=CC(C)(C)O. here inputs are CC(C)(C)Br and CC(C)(C)O and I was expecting the json response contains both the inputs but I got null as output
This is my urls.py file
@api_view(['GET'])
def result(request):
response = {}
solute = request.POST.get('solute')
solvent = request.POST.get('solvent')
results = [solute,solvent]
return Response({'result':results}, status=200)
I got null as output json response

CodePudding user response:
You are passing the data as query string [wiki], so you access this with request.GET [Django-doc]:
@api_view(['GET'])
def result(request):
response = {}
solute = request.GET.get('solute')
solvent = request.GET.get('solvent')
results = [solute,solvent]
return Response({'result':results}, status=200) 