当前位置: 首页>>代码示例>>Python>>正文


Python web.get方法代码示例

本文整理汇总了Python中aiohttp.web.get方法的典型用法代码示例。如果您正苦于以下问题:Python web.get方法的具体用法?Python web.get怎么用?Python web.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aiohttp.web的用法示例。


在下文中一共展示了web.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_settings_first

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import get [as 别名]
def test_settings_first(testdir, plugin):
    # When `hypothesis.settings` decorator is applied to a coroutine-based test before `parametrize`
    parameters = {"parameters": [integer(name="id", required=True)]}
    testdir.make_test(
        f"""
@schema.parametrize()
{"@pytest.mark.asyncio" if plugin == "pytest_asyncio" else ""}
@settings(max_examples=5)
async def test_(request, case):
    request.config.HYPOTHESIS_CASES += 1
    assert case.full_path == "/v1/users"
    assert case.method in ("GET", "POST")
""",
        pytest_plugins=[plugin],
        paths={"/users": {"get": parameters, "post": parameters}},
    )
    result = testdir.runpytest("-v", "-s")
    result.assert_outcomes(passed=2)
    # Then it should be executed as any other test
    result.stdout.re_match_lines([r"Hypothesis calls: 10$"]) 
开发者ID:kiwicom,项目名称:schemathesis,代码行数:22,代码来源:test_async.py

示例2: revocation_registries_created

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import get [as 别名]
def revocation_registries_created(request: web.BaseRequest):
    """
    Request handler to get revocation registries that current agent created.

    Args:
        request: aiohttp request object

    Returns:
        List of identifiers of matching revocation registries.

    """
    context = request.app["request_context"]

    search_tags = [
        tag for tag in vars(RevRegsCreatedQueryStringSchema)["_declared_fields"]
    ]
    tag_filter = {
        tag: request.query[tag] for tag in search_tags if tag in request.query
    }
    found = await IssuerRevRegRecord.query(context, tag_filter)

    return web.json_response({"rev_reg_ids": [record.revoc_reg_id for record in found]}) 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:24,代码来源:routes.py

示例3: get_registry

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import get [as 别名]
def get_registry(request: web.BaseRequest):
    """
    Request handler to get a revocation registry by identifier.

    Args:
        request: aiohttp request object

    Returns:
        The revocation registry

    """
    context = request.app["request_context"]

    registry_id = request.match_info["rev_reg_id"]

    try:
        revoc = IndyRevocation(context)
        revoc_registry = await revoc.get_issuer_rev_reg_record(registry_id)
    except StorageNotFoundError as err:
        raise web.HTTPNotFound(reason=err.roll_up) from err

    return web.json_response({"result": revoc_registry.serialize()}) 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:24,代码来源:routes.py

示例4: get_active_registry

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import get [as 别名]
def get_active_registry(request: web.BaseRequest):
    """
    Request handler to get an active revocation registry by cred def id.

    Args:
        request: aiohttp request object

    Returns:
        The revocation registry identifier

    """
    context = request.app["request_context"]

    cred_def_id = request.match_info["cred_def_id"]

    try:
        revoc = IndyRevocation(context)
        revoc_registry = await revoc.get_active_issuer_rev_reg_record(cred_def_id)
    except StorageNotFoundError as err:
        raise web.HTTPNotFound(reason=err.roll_up) from err

    return web.json_response({"result": revoc_registry.serialize()}) 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:24,代码来源:routes.py

示例5: query_features

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import get [as 别名]
def query_features(request: web.BaseRequest):
    """
    Request handler for inspecting supported protocols.

    Args:
        request: aiohttp request object

    Returns:
        The diclosed protocols response

    """
    context = request.app["request_context"]
    registry: ProtocolRegistry = await context.inject(ProtocolRegistry)
    results = registry.protocols_matching_query(request.query.get("query", "*"))

    return web.json_response({"results": {k: {} for k in results}}) 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:18,代码来源:routes.py

示例6: register

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import get [as 别名]
def register(app: web.Application):
    """Register routes."""

    app.add_routes(
        [
            web.get("/connections", connections_list, allow_head=False),
            web.get("/connections/{conn_id}", connections_retrieve, allow_head=False),
            web.post("/connections/create-static", connections_create_static),
            web.post("/connections/create-invitation", connections_create_invitation),
            web.post("/connections/receive-invitation", connections_receive_invitation),
            web.post(
                "/connections/{conn_id}/accept-invitation",
                connections_accept_invitation,
            ),
            web.post(
                "/connections/{conn_id}/accept-request", connections_accept_request
            ),
            web.post(
                "/connections/{conn_id}/establish-inbound/{ref_id}",
                connections_establish_inbound,
            ),
            web.post("/connections/{conn_id}/remove", connections_remove),
        ]
    ) 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:26,代码来源:routes.py

示例7: credential_exchange_publish_revocations

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import get [as 别名]
def credential_exchange_publish_revocations(request: web.BaseRequest):
    """
    Request handler for publishing pending revocations to the ledger.

    Args:
        request: aiohttp request object

    Returns:
        Credential revocation ids published as revoked by revocation registry id.

    """
    context = request.app["request_context"]
    body = await request.json()
    rrid2crid = body.get("rrid2crid")

    credential_manager = CredentialManager(context)

    try:
        results = await credential_manager.publish_pending_revocations(rrid2crid)
    except (RevocationError, StorageError, IssuerError, LedgerError) as err:
        raise web.HTTPBadRequest(reason=err.roll_up) from err
    return web.json_response({"rrid2crid": results}) 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:24,代码来源:routes.py

示例8: invite_message_handler

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import get [as 别名]
def invite_message_handler(self, request: web.BaseRequest):
        """
        Message handler for invites.

        Args:
            request: aiohttp request object

        Returns:
            The web response

        """
        if request.query.get("c_i"):
            return web.Response(
                text="You have received a connection invitation. To accept the "
                "invitation, paste it into your agent application."
            )
        else:
            return web.Response(status=200) 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:20,代码来源:http.py

示例9: register

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import get [as 别名]
def register(app: web.Application):
    """Register routes."""

    app.add_routes(
        [
            web.get("/wallet/did", wallet_did_list, allow_head=False),
            web.post("/wallet/did/create", wallet_create_did),
            web.get("/wallet/did/public", wallet_get_public_did, allow_head=False),
            web.post("/wallet/did/public", wallet_set_public_did),
            web.post("/wallet/set-did-endpoint", wallet_set_did_endpoint),
            web.get(
                "/wallet/get-did-endpoint", wallet_get_did_endpoint, allow_head=False
            ),
            web.patch("/wallet/did/local/rotate-keypair", wallet_rotate_did_keypair),
        ]
    ) 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:18,代码来源:routes.py

示例10: setup_routes

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import get [as 别名]
def setup_routes(self):
        self.app.add_routes([web.get('', self.list_pseudonyms),

                             web.get('/{pseudonym_name}/schemas', self.list_schemas),

                             web.get('/{pseudonym_name}/public_key', self.get_pseudonym_public_key),
                             web.get('/{pseudonym_name}/unload', self.unload_pseudonym),
                             web.get('/{pseudonym_name}/remove', self.remove_pseudonym),

                             web.get('/{pseudonym_name}/credentials', self.list_pseudonym_credentials),
                             web.get('/{pseudonym_name}/credentials/{subject_key}', self.list_subject_credentials),
                             web.get('/{pseudonym_name}/peers', self.list_pseudonym_peers),

                             web.put('/{pseudonym_name}/allow/{verifier_key}', self.allow_pseudonym_verification),
                             web.put('/{pseudonym_name}/disallow/{verifier_key}', self.disallow_pseudonym_verification),
                             web.put('/{pseudonym_name}/request/{authority_key}', self.create_pseudonym_credential),

                             web.put('/{pseudonym_name}/attest/{subject_key}', self.attest_pseudonym_credential),
                             web.put('/{pseudonym_name}/verify/{subject_key}', self.verify_pseudonym_credential),

                             web.get('/{pseudonym_name}/outstanding/attestations', self.list_pseudonym_outstanding_attestations),
                             web.get('/{pseudonym_name}/outstanding/verifications', self.list_pseudonym_outstanding_verifications),

                             web.get('/{pseudonym_name}/verifications', self.list_pseudonym_verification_output)
                             ]) 
开发者ID:Tribler,项目名称:py-ipv8,代码行数:27,代码来源:identity_endpoint.py

示例11: list_subject_credentials

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import get [as 别名]
def list_subject_credentials(self, request):
        channel = await self.communication_manager.load(request.match_info['pseudonym_name'],
                                                        request.headers.get('X-Rendezvous'))

        subject = None
        for peer in channel.peers:
            if peer.public_key.key_to_bin() == ez_b64_decode(request.match_info['subject_key']):
                subject = peer
                break
        if subject is None:
            return Response({"success": False, "error": "failed to find subject"})

        return Response({"names": [{
            "name": data[0],
            "hash": ez_b64_encode(strip_sha1_padding(attribute_hash)),
            "metadata": data[1],
            "attesters": [ez_b64_encode(attester) for attester in data[2]]
        }
            for attribute_hash, data in channel.get_attributes(subject).items()]
        }) 
开发者ID:Tribler,项目名称:py-ipv8,代码行数:22,代码来源:identity_endpoint.py

示例12: allow_pseudonym_verification

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import get [as 别名]
def allow_pseudonym_verification(self, request):
        parameters = await request.json()
        if 'name' not in parameters:
            return Response({"error": "incorrect parameters"}, status=HTTP_BAD_REQUEST)

        channel = await self.communication_manager.load(request.match_info['pseudonym_name'],
                                                        request.headers.get('X-Rendezvous'))
        verifier = None
        for peer in channel.peers:
            if peer.public_key.key_to_bin() == ez_b64_decode(request.match_info['verifier_key']):
                verifier = peer
                break
        if verifier is None:
            return Response({"success": False, "error": "failed to find verifier"})

        channel.allow_verification(verifier, parameters['name'])

        return Response({"success": True}) 
开发者ID:Tribler,项目名称:py-ipv8,代码行数:20,代码来源:identity_endpoint.py

示例13: disallow_pseudonym_verification

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import get [as 别名]
def disallow_pseudonym_verification(self, request):
        parameters = await request.json()
        if 'name' not in parameters:
            return Response({"error": "incorrect parameters"}, status=HTTP_BAD_REQUEST)

        channel = await self.communication_manager.load(request.match_info['pseudonym_name'],
                                                        request.headers.get('X-Rendezvous'))
        verifier = None
        for peer in channel.peers:
            if peer.public_key.key_to_bin() == ez_b64_decode(request.match_info['verifier_key']):
                verifier = peer
                break
        if verifier is None:
            return Response({"success": False, "error": "failed to find verifier"})

        channel.disallow_verification(verifier, parameters['name'])

        return Response({"success": True}) 
开发者ID:Tribler,项目名称:py-ipv8,代码行数:20,代码来源:identity_endpoint.py

示例14: create_pseudonym_credential

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import get [as 别名]
def create_pseudonym_credential(self, request):
        parameters = await request.json()
        if 'name' not in parameters or 'schema' not in parameters:
            return Response({"error": "incorrect parameters"}, status=HTTP_BAD_REQUEST)

        channel = await self.communication_manager.load(request.match_info['pseudonym_name'],
                                                        request.headers.get('X-Rendezvous'))
        authority = None
        for peer in channel.peers:
            if peer.public_key.key_to_bin() == ez_b64_decode(request.match_info['authority_key']):
                authority = peer
                break
        if authority is None:
            return Response({"success": False, "error": "failed to find authority"})

        metadata = parameters['metadata'] if 'metadata' in parameters else {}
        channel.request_attestation(authority, parameters['name'], parameters['schema'], metadata)

        return Response({"success": True}) 
开发者ID:Tribler,项目名称:py-ipv8,代码行数:21,代码来源:identity_endpoint.py

示例15: attest_pseudonym_credential

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import get [as 别名]
def attest_pseudonym_credential(self, request):
        parameters = await request.json()
        if 'name' not in parameters or 'value' not in parameters:
            return Response({"error": "incorrect parameters"}, status=HTTP_BAD_REQUEST)

        channel = await self.communication_manager.load(request.match_info['pseudonym_name'],
                                                        request.headers.get('X-Rendezvous'))

        subject = None
        for peer in channel.peers:
            if peer.public_key.key_to_bin() == ez_b64_decode(request.match_info['subject_key']):
                subject = peer
                break
        if subject is None:
            return Response({"success": False, "error": "failed to find subject"})

        channel.attest(subject, parameters["name"], ez_b64_decode(parameters["value"]))

        return Response({"success": True}) 
开发者ID:Tribler,项目名称:py-ipv8,代码行数:21,代码来源:identity_endpoint.py


注:本文中的aiohttp.web.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。