1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Setting up Flask HTTPS server

Discussão em 'Python' iniciado por Stack, Setembro 12, 2024.

  1. Stack

    Stack Membro Participativo

    I have a task to add certificates to my Flask server. The server is responsive with HTTP requests.

    Does anybody have experience how to set up Flask HTTPS server? I generated private and public keys, with the certbot tool. Information about this tool are here: https://certbot.eff.org/instructions?ws=webproduct&os=snap

    In summary, certbot allows you to create private and public keys encoded as .pem files. Which are then used for encrypting and decrypting the traffic which is exchanged between client and server.

    I use the waitress library for serving the content to the clients. This is the line which does this job:

    serve(app, host='0.0.0.0', port=80)


    Does anybody know how to transition from here to the state where somebody can access my page with HTTPS protocol? In other words, do HTTPS handshake and exchange the data?

    I tried with this line:

    serve(app, host='0.0.0.0', port=5000, url_scheme='https',
    certfile='path/to/certfile.pem', keyfile='path/to/keyfile.pem')


    Which I found this line with perplexity: https://www.perplexity.ai/search/run-flask-https-server-jPPLZHcERamQ5YBqFlVIBQ

    Continue reading...

Compartilhe esta Página