Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PYTHON DJANGO I keep getting this error: raise JSONDecodeError(Expecting value, s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) WHY? 1
PYTHON DJANGO
I keep getting this error:
raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
WHY?
1 2 3 from django. shortcuts import render from django.http import JsonResponse # Create your views here. import json import pandas as pd 4 5 6 7 import joblib 8 model=joblib.load('modelPipeline.pkl') 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 def scoreJson (request): print (request.body) data =json. loads (request.body) dataF=pd.DataFrame({ 'x':data}). transpose() score=model.predict_proba (dataF) [:,-1][0] score=float(score) return JsonResponse({ 'score':score}) def scoreFile(request): return JsonResponse({ 'score":1}] PROBLEMS OUTPUT TERMINAL TERMINAL 1: Python + A ango/views/decorators/csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "/Users/benmai/ModelBackend/firstPage/views.py", line 15, in scor eJson data =json. loads( request.body) File "/Library/Frameworks/Python. framework/Versions/3.9/lib/python3.9/ json/__init__.py", line 346, in loads return _default_decoder.decode(s) File "/Library/Frameworks/Python. framework/Versions/3.9/lib/python3.9/ json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/Library/Frameworks/Python. framework/Versions/3.9/lib/python3.9/ json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char ) (13/Mar/2021 04:25:31] "GET /scoreJson HTTP/1.1" 500 78016Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started