Python Flask - request.json returns None Type instead of json dictionary

后端 未结 1 1206
旧巷少年郎
旧巷少年郎 2021-01-24 01:55

I\'m writing a very simple demo webapp, and I can\'t seem to pass a json object from js to python using ajax.

I\'ve tried a number of suggesti

相关标签:
1条回答
  • 2021-01-24 02:31

    Because you are not sending JSON, to the flask app (see this and this). Your current code results in a standard urlencoded form post. Which in turn results in an entry being populated in request.form

     request.form.get('word')
    

    Switch to a json post as per the guidelines in the above Q&As to access the data through request.json.

    0 讨论(0)
提交回复
热议问题