Answered step by step
Verified Expert Solution
Link Copied!

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?

image text in transcribed

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 78016

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions

Question

1 . Television News channels importantance of our Life pattern ?

Answered: 1 week ago

Question

1. How is the newspaper help to our daily life?

Answered: 1 week ago

Question

1. Prepare a short profile of Mikhail Zoshchenko ?

Answered: 1 week ago

Question

What is psychology disorder?

Answered: 1 week ago

Question

Know how productivity improvements impact quality and value.

Answered: 1 week ago

Question

Recommend the key methods to improve service productivity.

Answered: 1 week ago