app.py 文件源码

python
阅读 15 收藏 0 点赞 0 评论 0

项目:toshi-admin-service 作者: toshiapp 项目源码 文件源码
def force_https(request):
    host = request.headers.get('Host', '')
    # get scheme, first by checking the x-forwarded-proto (from nginx/heroku etc)
    # then falling back on whether or not there is an sslcontext
    scheme = request.headers.get(
        'x-forwarded-proto',
        "https" if request.transport.get_extra_info('sslcontext') else "http")
    if not host.startswith("localhost:") and scheme != "https":
        url = urlunparse((
            "https",
            host,
            request.path,
            None,
            request.query_string,
            None))
        return redirect(url)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号