Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

532
Views
How to create button that runs python code?

I'm learning python currently and I've made a password generator. I would like to make it so the script runs when you press a button, so you don't have to refresh the page to get a new password. I'm not sure where to start so any help would be appreciated. Below is my python script. I'm using flask.

 <py-script> 
    num = "0123456789"
    lowercase = "abcdefghijklmnopqrstuvwxyz"
    uppercase = lowercase.upper()
    special = "!@#$%^&*()_+~`|}{[]:;?><,. /-="

    all = num+lowercase+uppercase+special

    from random import choice
    password = "".join(
    choice(all) for i in range(16)
      )
    print (password)
 </py-script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

*Press html Button more than once to work effectively*

    <html>
        <head>
          <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
          <link rel = 'stylesheet' href = "https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css">
          <script defer src="https://pyscript.net/alpha/pyscript.js"></script>
        </head>
    
      <body>
        <button id = "show_password" class = "btn btn-primary" type = "submit" pys-onClick="show_password">Password Generator</button>
        <div id="outputDiv" style="margin-top: 10px;margin-bottom: 10px;"></div>
       
        <py-script> 
                 from random import choice
                 def show_password(*args, **kwargs):
                    output = Element("outputDiv")
                    num = "0123456789"
                    lowercase = "abcdefghijklmnopqrstuvwxyz"
                    uppercase = lowercase.upper()
                    special = "!@#$%^&*()_+~`|}{[]:;?><,. /-="
    
                    all = num+lowercase+uppercase+special
                    password = "".join(choice(all) for i in range(16))
                    output.write(password)
        </py-script>
      </body>
    </html>

enter image description here

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!