I am trying to send image to the django server. Here is my code:
@csrf_exempt
def classify_image(request):
if request.method == 'POST' and request.FILES:
try:
image = request.FILES['file']
if image:
img_b64 = b64encode(image.read())
res = main.classify_image(img_b64)
return JsonResponse({
"status": "ok",
"result": {
"class": res[0],
"confidence": res[1],
}
})
except Exception as e:
return JsonResponse({
"status": "error",
"error": str(e)
})
return JsonResponse({
"status": "error",
"error": "Image file is required"
})
I am sending requesting using postman, here's the sample
The weird thing is the code was working perfectly fine some hours ago. Later I didn't change a single thing but it was throwing error.