Https with Http in Flask Python

前端 未结 4 781
南方客
南方客 2021-02-04 06:25

I have a client server application. I managed to make them connect over https using SSl encryption using this

    context = SSL.Context(SSL.SSLv3_METHOD)
    con         


        
4条回答
  •  名媛妹妹
    2021-02-04 06:43

    My I suggest trying out Flask-SSLify - https://github.com/kennethreitz/flask-sslify

    Usage

    Usage is pretty simple:

    from flask import Flask
    from flask_sslify import SSLify
    
    app = Flask(__name__)
    sslify = SSLify(app)
    

    If you make an HTTP request, it will automatically redirect:

    $ curl -I http://secure-samurai.herokuapp.com/
    HTTP/1.1 302 FOUND
    Content-length: 281
    Content-Type: text/html; charset=utf-8
    Date: Sun, 29 Apr 2012 21:39:36 GMT
    Location: https://secure-samurai.herokuapp.com/
    Server: gunicorn/0.14.2
    Strict-Transport-Security: max-age=31536000
    Connection: keep-alive
    

    Install

    Installation is simple too:

    $ pip install Flask-SSLify
    

提交回复
热议问题