Difference between revisions of "Flask HTTPS"

From UVOO Tech Wiki
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...")
 
Line 27: Line 27:
 
$ 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/

Revision as of 17:19, 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 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/