本文整理汇总了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$"])
示例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]})
示例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()})
示例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()})
示例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}})
示例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),
]
)
示例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})
示例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)
示例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),
]
)
示例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)
])
示例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()]
})
示例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})
示例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})
示例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})
示例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})