Difference between revisions of "Flask HTTPS"
Jump to navigation
Jump to search
Line 4: | Line 4: | ||
``` | ``` | ||
− | pip install pyopenssl | + | pip install flask pyopenssl |
flask run --cert=adhoc | flask run --cert=adhoc | ||
``` | ``` |
Latest revision as of 17:20, 17 August 2022
https://blog.miguelgrinberg.com/post/running-your-flask-application-over-https
You really should use nginx or something faster but this is nice sometimes especially for testing
pip install flask pyopenssl flask run --cert=adhoc
openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run(ssl_context=('cert.pem', 'key.pem'))
Alternatively, you can add the --cert and --key options to the flask run command if you are using Flask 1.x or newer:
$ flask run --cert=cert.pem --key=key.pem
PCAP decode
https://minnmyatsoe.com/2016/01/26/using-tshark-to-decrypt-ssl-tls-packets/