Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

531
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda