correct status code
This commit is contained in:
@@ -96,7 +96,7 @@ def strokedatajson_v2(request,id):
|
||||
try:
|
||||
id = int(id)
|
||||
except ValueError:
|
||||
return HttpResponse("Not a valid workout number",stauts=400)
|
||||
return HttpResponse("Not a valid workout number",status=400)
|
||||
|
||||
if request.method == 'GET':
|
||||
columns = ['spm','time','hr','pace','power','distance']
|
||||
@@ -112,9 +112,10 @@ def strokedatajson_v2(request,id):
|
||||
if request.method == 'POST':
|
||||
checkdata, r = dataprep.getrowdata_db(id=row.id)
|
||||
if not checkdata.empty:
|
||||
return HttpResponse("Duplicate Error",400)
|
||||
return HttpResponse("Duplicate Error",status=400)
|
||||
|
||||
df = pd.DataFrame()
|
||||
print(request.POST)
|
||||
|
||||
try:
|
||||
df = pd.read_json(request.POST['data'],orient='split')
|
||||
@@ -122,7 +123,7 @@ def strokedatajson_v2(request,id):
|
||||
try:
|
||||
df = pd.read_json(request.POST['strokedata'],orient='split')
|
||||
except:
|
||||
return HttpResponse("No JSON object could be decoded",400)
|
||||
return HttpResponse("No JSON object could be decoded",status=400)
|
||||
|
||||
df.index = df.index.astype(int)
|
||||
df.sort_index(inplace=True)
|
||||
@@ -134,12 +135,12 @@ def strokedatajson_v2(request,id):
|
||||
try:
|
||||
time = df['t']/10.
|
||||
except KeyError:
|
||||
return HttpResponse("Missing time",400)
|
||||
return HttpResponse("Missing time",status=400)
|
||||
|
||||
try:
|
||||
spm = df['spm']
|
||||
except KeyError:
|
||||
return HttpResponse("Missing spm",400)
|
||||
return HttpResponse("Missing spm",status=400)
|
||||
|
||||
try:
|
||||
distance = df['distance']
|
||||
@@ -147,7 +148,7 @@ def strokedatajson_v2(request,id):
|
||||
try:
|
||||
distance = df['d']/10.
|
||||
except KeyError:
|
||||
return HttpResponse("Missing distance",400)
|
||||
return HttpResponse("Missing distance",status=400)
|
||||
|
||||
try:
|
||||
pace = df['pace']/1.e3
|
||||
@@ -155,7 +156,7 @@ def strokedatajson_v2(request,id):
|
||||
try:
|
||||
pace = df['p']/10.
|
||||
except KeyError:
|
||||
return HttpResponse("Missing pace",400)
|
||||
return HttpResponse("Missing pace",status=400)
|
||||
|
||||
|
||||
|
||||
@@ -320,13 +321,13 @@ def strokedatajson(request,id):
|
||||
if request.method == 'POST':
|
||||
checkdata,r = dataprep.getrowdata_db(id=row.id)
|
||||
if not checkdata.empty:
|
||||
return HttpResponse("Duplicate Error",409)
|
||||
return HttpResponse("Duplicate Error",status=409)
|
||||
# strokedata = request.POST['strokedata']
|
||||
# checking/validating and cleaning
|
||||
try:
|
||||
strokedata = json.loads(request.POST['strokedata'])
|
||||
except:
|
||||
return HttpResponse("No JSON object could be decoded",400)
|
||||
return HttpResponse("No JSON object could be decoded",status=400)
|
||||
|
||||
df = pd.DataFrame(strokedata)
|
||||
df.index = df.index.astype(int)
|
||||
|
||||
Reference in New Issue
Block a user