Difference between revisions of "Flask HTTPS"
Jump to navigation
Jump to search
(Created page with "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 testi...") |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
``` | ``` | ||
− | pip install pyopenssl | + | pip install flask pyopenssl |
flask run --cert=adhoc | flask run --cert=adhoc | ||
``` | ``` | ||
Line 23: | Line 23: | ||
if __name__ == "__main__": | if __name__ == "__main__": | ||
app.run(ssl_context=('cert.pem', 'key.pem')) | 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: | 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 | $ flask run --cert=cert.pem --key=key.pem | ||
``` | ``` | ||
+ | |||
+ | |||
+ | # PCAP decode | ||
+ | https://minnmyatsoe.com/2016/01/26/using-tshark-to-decrypt-ssl-tls-packets/ |
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/