SSL been a mandatory stuff in all the websites nowadays. Lets see how to configure the free letsencrypt ssl in python flask application. Setting up the SSL in python flask applications are extremely simpler than all the other tech stacks.
Prerequisite:
Already letsencrypt is installed and created the free certificate for your domain.
Lets configure the SSL now for python flask application. Include the context with the cert and privkey pem files which is auto generated or provided by letsencrypt package during the free ssl creation for your domain.
Add the same with ssl_context in the app.run in your python flask application.
import ssl context = ('/etc/letsencrypt/live/ngdeveloper.com/cert.pem','/etc/letsencrypt/live/ngdeveloper/privkey.pem') if __name__ == '__main__': app.run(host='0.0.0.0',port=4999, ssl_context=context)