i have a python file that i want to run in a html file when a button is pressed using PyScript, how would i do this?

  Kiến thức lập trình

so i have a python file called main.py that i want to run when a button is pressed in a website i am creating but am unsure of how to go about this. i have looked at several different examples on the PyScript website but nothing seems to be what i want. is it possible and if so how would i do it?

html code:

<!DOCTYPE html> 
<html> 
  
<head> 
    <title>Secure Login</title> 
    <link rel="stylesheet" 
          href="style.css"> 
    <link rel=”stylesheet” href=”htpps://pyscript.net/alpha/pyscript.css” />
  <script defer 
  src=”htpps://pyscript.net/alpha/pyscript.js”>
  </script>
</head> 
  
<body> 
    <div class="main"> 
        <h1>Secure Login</h1> 
        <h3>Enter your login credentials</h3> 
        <p>Not registered?  
              <a href="#" 
               style="text-decoration: none;"> 
                Create an account 
            </a> 
        </p> 
    </div> 
</body> 
  
</html>
<script>
  function runpython() {
      <py-script src=”/my_own_file.py”>
      </py-script>
  }
</script> 
<button onclick="runpython()">please work</button>

New contributor

Joshua Carlson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT