« first day  last day (14 days later) » 

7:59 AM
Its a Json object
{"Studios":["warner","tf1","gaumont","pathe","studiocanal","francetv","m6snd"],"‌​Platforms":["orange","itunes","sfr"],"VODEST":["vod","est"],"SDHD":["sd","hd"],"C‌​ategory":["film","tv","others"],"Genre":["thriller","action","drama","horror"],"P‌​eriod":{"From":["W15"],"To":["W26"]}}
Apologies for the late reply! I guess its the different time zones!
 
8:47 AM
Alright, nested data is a little weird when sent through post requests. Also it looks like I was wrong when I told you to use request.json. Try clearing your method and looking at the result of print(request.forms.__dict__)
That output should give you a better idea of what I'm talking about
 
9:08 AM
I am sorry but i dont think I understand what you mean here. Could you elaborate if you dont mind.
 
9:19 AM
But when I just print request.forms.__dict__ i get the Json object
 
can you post what the output is for you?
 
{'dict': {'jsontring': ['{"Studios":["warner1"27.0.0.1 - - [26/Jun/2015:11:30:46
+0200] "GET /calendar2.gif HTTP/1.1" 304 - "http://localhost:8080/index.html" "
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0"
,"tf1","gaumont","pathe","studiocanal","francetv","m6snd"],"Platforms":["orange"
,"itunes","sfr"],"VODEST":["vod","est"],"SDHD":["sd","hd"],"Category":["film","t
v","others"],"Genre":["thriller","action","drama","horror"],"Period":{"From":["W
15"],"To":["W26"]}}']}}
It doesnt look very consistent
 
9:37 AM
Yeah thats interesting, what does request.forms.get('jsonstring') give you?
 
You know what? I guess i got it to work. Will update you in a minute
You sir, are a champ :)
This was the problem
Remember the first method I used
_studios = _jsonparams.Studios
That didnt work
And when it was changed to _studios = _jsonparams["Studios"]
It worked perfectly
What difference does it make? Any idea?
 
 
5 hours later…
2:40 PM
Thats just because _studios is a dictionary, and the syntax to access values in a python dictionary is just dict[key], its a little different syntax from javascript objects where you would be able to access a value with dict.key
 
Great! Thank you so much for hanging on to my stupidity :)
 
3:39 PM
You managed to figure it out, I wouldn't call that stupidity :) sorry I wasn't of more help, I usually use Angularjs with bottle and it looks like the post requests get send a little differently
 
3:50 PM
But with your method, so you get the credit :) If not for you god knows for homy more days I would have been stuck with this. World need more people like you definitely :)
 
4:01 PM
What do you want to do about the question? We could get rid of the comments and if you send over the working function I could write an answer. Or you could answer it yourself. Your call
 
4:18 PM
We just changed the dictionary access method. You could just leave an anwer mentioning the method change. Ok? I would be a simple 2 line answer.
Or maybe if you want the code sinppet
@app.post('/salesvolume')
def salesvolume(db):
jsonstring = request.forms.get('jstring')
_jsonparams = json.loads(jsonstring)
_studios = _jsonparams["Studios"]

ret = `Some Json`
return json.loads(ret)
app.run(server='paste', host='localhost', port=8080, debug=True, reloader=True)
 
Sounds good, Ill take care of it after lunch.
 

« first day  last day (14 days later) »