Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

537
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda