compliance.py 文件源码

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

项目:google-auth-library-python 作者: GoogleCloudPlatform 项目源码 文件源码
def server(self):
        """Provides a test HTTP server.

        The test server is automatically created before
        a test and destroyed at the end. The server is serving a test
        application that can be used to verify requests.
        """
        app = flask.Flask(__name__)
        app.debug = True

        # pylint: disable=unused-variable
        # (pylint thinks the flask routes are unusued.)
        @app.route('/basic')
        def index():
            header_value = flask.request.headers.get('x-test-header', 'value')
            headers = {'X-Test-Header': header_value}
            return 'Basic Content', http_client.OK, headers

        @app.route('/server_error')
        def server_error():
            return 'Error', http_client.INTERNAL_SERVER_ERROR

        @app.route('/wait')
        def wait():
            time.sleep(3)
            return 'Waited'
        # pylint: enable=unused-variable

        server = WSGIServer(application=app.wsgi_app)
        server.start()
        yield server
        server.stop()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号