jeudi 1 août 2019

How to handle POST data from a python script into a javascript function

I have the following simple python script:

import requests 
data = {'name'=test, 'age'=12} 
requests.post(url = "localhost/test.html", data = data) 

with the "test.html" webpage like:

<!DOCTYPE html>
<html>
  <head>
    <script>
      $(function(){
        $('#myfunction').myfunction({
          ...
          data: [ XXX ]
        });
      });
    </script>
  </head>
  <body>
    <h3>Test</h3>
  </body>
</html>


What I want to do is to handle the POST data from my python script into the javascript function. In other abstract words, I want to have the XXX replaced with {'name'=test, 'age'=12}.

Is anyone know how to do this ?




Aucun commentaire:

Enregistrer un commentaire