Answers for "how to send data from javascript to python flask"

0

how to send data from javascript to python flask

/* You can create a node.js web server and use Fetch/AJAX POST requests to send 
data. 
*/
/* Python Route Code */
@app.route('/postmethod', methods = ['POST'])
def get_post_javascript_data():
    jsdata = request.form['javascript_data']
    return json.loads(jsdata)[0]
/* Javascript Send Data */
fetch('Yourdomain.com/postmethod', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
  	'foo': 'bar'
  }),
})
  .then((res) => res.json())
  .then((data) => {
    // Do some stuff ...
  })
Posted by: Guest on August-17-2021

Code answers related to "how to send data from javascript to python flask"

Code answers related to "Javascript"

Browse Popular Code Answers by Language