views.py 文件源码

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

项目:beesly 作者: bincyber 项目源码 文件源码
def after_request(resp):
    """
    Adds HTTP Headers to the response

    Arguments
    ----------
    resp : flask.Response object
      the Flask response object
    """
    resp.headers['Cache-Control'] = 'no-cache'

    if app.config['DEV']:
        resp.headers['Access-Control-Allow-Origin'] = '*'
        resp.headers['Access-Control-Allow-Methods'] = 'GET, POST'
        resp.headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept'

        source_ip = get_real_source_ip()

        structured_log(
            level='info',
            msg="HTTP Request",
            method=request.method,
            uri=request.path,
            status=resp.status_code,
            src_ip=source_ip,
            protocol=request.environ['SERVER_PROTOCOL'],
            user_agent=request.environ.get('HTTP_USER_AGENT', '-')
        )

    return resp
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号