コード例 #1
0
ファイル: test_decorator.py プロジェクト: koug44/sanic-gzip
    def setUpClass(cls) -> None:
        cls.app = Sanic(name='sanic-gzip-test')
        cls.compressor = Compress(compress_min_size=1)

        @cls.app.route(uri='/function')
        @cls.compressor.compress()
        async def get(request):
            return handle(request)

        class View(HTTPMethodView):
            @cls.compressor.compress()
            async def get(self, request):
                return handle(request)

        cls.app.add_route(handler=View.as_view(), uri='/view')
コード例 #2
0
                len(set(package['language']['versions']) & set(python)) == 0:
            continue

        # Check test flag
        if 'test_only' in package and package['test_only'] and not test:
            continue

        results.append(package)

    return results


# Create the sanic app
app = Sanic('addon-proxy')
CORS(app)
compress = Compress()


# Serve the list
@app.route('/addons')
@compress.compress()
async def get_list(request):
    """Get the add-on list which matches a set of filters."""
    args = request.args
    ua = request.headers.get('User-Agent', None)
    _REQUESTS.append((time.time(), ua))

    # Defaults based on 0.6.X
    arch = args['arch'][0] if 'arch' in args else None
    node = args['node'][0] if 'node' in args else '57'
    python = \