wsgi.py 文件源码

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

项目:fleece 作者: racker 项目源码 文件源码
def build_wsgi_environ_from_event(event):
    """Create a WSGI environment from the proxy integration event."""
    params = event.get('queryStringParameters')
    environ = EnvironBuilder(method=event.get('httpMethod') or 'GET',
                             path=event.get('path') or '/',
                             headers=event.get('headers') or {},
                             data=event.get('body') or b'',
                             query_string=params or {}).get_environ()
    environ['SERVER_PORT'] = 443
    if 'execute-api' in environ['HTTP_HOST']:
        # this is the API-Gateway hostname, which takes the stage as the first
        # script path component
        environ['SCRIPT_NAME'] = '/' + event['requestContext'].get('stage')
    else:
        # we are using our own hostname, nothing gets added to the script path
        environ['SCRIPT_NAME'] = ''
    environ['wsgi.url_scheme'] = 'https'
    environ['lambda.event'] = event
    return environ
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号