随笔 | Python的Flask强制使http跳转到https页面

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了随笔 | Python的Flask强制使http跳转到https页面相关的知识,希望对你有一定的参考价值。

@app.before_request

def before_request():

    if request.url.startswith(‘http://‘):

        url = request.url.replace(‘http://‘, ‘https://‘, 1)

        code = 301

        return redirect(url, code=code)

以上是关于随笔 | Python的Flask强制使http跳转到https页面的主要内容,如果未能解决你的问题,请参考以下文章