Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138134

How to call a python function from a Javascript in a Webpage

$
0
0

I write the html code as bellow,

<!DOCTYPE html>
<html>
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    </head>
    <body>
        <button onclick="Call_pyth()">Call Fun</button>
        <p id="para"></p>
        <script>
            function Call_pyth(){
                $.ajax({
                type: "POST",
                url: "~/Pythoncode.py",
                data: { param: "Balgopal"}
                }).done(function( o ) {
                    console.log("Called");
                    console.log(o)
                });
            }
        </script>
    </body>
</html>

And my Python file is

def Name(x):
    return x*2

please help me in this case ,That how can I call that function from that html file.


Viewing all articles
Browse latest Browse all 138134

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>