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


Python web.post方法代码示例

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


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

示例1: code

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import post [as 别名]
def code(self, request: web.Request):
        if 'code' not in request.query:
            raise web.HTTPFound("/register?" + urlencode({"redirect": request.url}))

        code = request.query["code"]
        data = {
            "code": code,
            "grant_type": "authorization_code",
            "redirect_uri": "http://api.typheus.me/hub",
            "client_id": self.client_id,
            "client_secret": self.client_secret,
            "scope": 'identify guilds'
        }
        response = await self.session.post(
            f"https://discordapp.com/api/oauth2/token",
            data=urlencode(data),
            headers={'Content-Type': "application/x-www-form-urlencoded"}
        )
        js = await response.json()
        if 'error' in js:
            raise web.HTTPServerError(reason=f"Invalid code or redirect {js['error']}")
        token = js['access_token']
        logging.info("Received Discord OAuth2 code, grabbing token")
        raise web.HTTPFound(f"/hub?token={token}") 
开发者ID:henry232323,项目名称:RPGBot,代码行数:26,代码来源:server.py

示例2: test_transport_coverage

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import post [as 别名]
def test_transport_coverage(self):
        transport = HttpTransport()
        assert transport.wire_format is None
        transport.wire_format = JsonWireFormat()
        assert transport.wire_format is not None

        await transport.start()

        with pytest.raises(OutboundTransportError):
            await transport.handle_message(None, None, None)

        with async_mock.patch.object(
            transport, "client_session", async_mock.MagicMock()
        ) as mock_session:
            mock_response = async_mock.MagicMock(status=404)
            mock_session.post = async_mock.MagicMock(
                return_value=async_mock.MagicMock(
                    __aenter__=async_mock.CoroutineMock(return_value=mock_response)
                )
            )
            with pytest.raises(OutboundTransportError):
                await transport.handle_message(None, "dummy", "http://localhost")

        await transport.__aexit__(KeyError, KeyError("just a drill"), None) 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:26,代码来源:test_http_transport.py

示例3: register

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import post [as 别名]
def register(app: web.Application):
    """Register routes."""
    app.add_routes(
        [
            web.post(
                "/credential-definitions",
                credential_definitions_send_credential_definition,
            ),
            web.get(
                "/credential-definitions/created",
                credential_definitions_created,
                allow_head=False,
            ),
            web.get(
                "/credential-definitions/{cred_def_id}",
                credential_definitions_get_credential_definition,
                allow_head=False,
            ),
        ]
    ) 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:22,代码来源:routes.py

示例4: register

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import post [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

示例5: main

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import post [as 别名]
def main():
    app = web.Application()
    s = SwaggerFile(
        app,
        spec_file="petstore.yaml",
        swagger_ui_settings=SwaggerUiSettings(path="/docs"),
    )
    s.add_routes(
        [
            web.get("/pets", get_all_pets),
            web.get("/pets/{pet_id}", get_one_pet),
            web.delete("/pets/{pet_id}", delete_one_pet),
            web.post("/pets", create_pet),
        ]
    )
    app["storage"] = {}
    web.run_app(app) 
开发者ID:hh-h,项目名称:aiohttp-swagger3,代码行数:19,代码来源:main.py

示例6: main

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import post [as 别名]
def main():
    app = web.Application()
    s = SwaggerDocs(
        app,
        title="Swagger Petstore",
        version="1.0.0",
        components="components.yaml",
        swagger_ui_settings=SwaggerUiSettings(path="/docs"),
    )
    s.add_routes(
        [
            web.get("/pets", get_all_pets),
            web.get("/pets/{pet_id}", get_one_pet),
            web.delete("/pets/{pet_id}", delete_one_pet),
            web.post("/pets", create_pet),
        ]
    )
    app["storage"] = {}
    web.run_app(app) 
开发者ID:hh-h,项目名称:aiohttp-swagger3,代码行数:21,代码来源:main.py

示例7: __init__

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import post [as 别名]
def __init__(self, bot: Bot, host: str, port: int):
        self.bot = bot
        self.app = web.Application(middlewares=[web.normalize_path_middleware()])
        self.app.add_routes([
            web.post('/callback', self.callback)
        ])
        cors = aiohttp_cors.setup(self.app, defaults={
            "*": aiohttp_cors.ResourceOptions(
                    allow_credentials=True,
                    expose_headers="*",
                    allow_headers="*",
                )
        })
        ufw_resource = cors.add(self.app.router.add_resource("/ufw/{wallet}"))
        cors.add(ufw_resource.add_route("GET", self.ufw)) 
        wfu_resource = cors.add(self.app.router.add_resource("/wfu/{user}"))
        cors.add(wfu_resource.add_route("GET", self.wfu))
        users_resource = cors.add(self.app.router.add_resource("/users"))
        cors.add(users_resource.add_route("GET", self.users))
        self.logger = logging.getLogger()
        self.host = host
        self.port = port
        self.min_amount = 10 if Env.banano() else 0.1 
开发者ID:bbedward,项目名称:graham_discord_bot,代码行数:25,代码来源:server.py

示例8: main

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import post [as 别名]
def main():
    """Create connection and start web server."""
    args = config()
    conn = StaticConnection(
        (args.my_verkey, args.my_sigkey),
        their_vk=args.their_verkey,
        endpoint=args.endpoint,
    )

    bmc = BasicMessageCounter()
    conn.route_module(bmc)

    async def handle(request):
        """ aiohttp handle POST. """
        await conn.handle(await request.read())
        raise web.HTTPAccepted()

    app = web.Application()
    app.add_routes([web.post('/', handle)])

    web.run_app(app, port=args.port) 
开发者ID:hyperledger,项目名称:aries-staticagent-python,代码行数:23,代码来源:webserver_with_module.py

示例9: main

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import post [as 别名]
def main():
    logging.basicConfig()
    app = web.Application()
    app.add_routes([
        web.post('/graphql', handle_graphql),
    ])
    app['graphql-endpoint'] = AsyncGraphQLEndpoint(
        Engine(AsyncIOExecutor()), QUERY_GRAPH, MUTATION_GRAPH,
    )
    web.run_app(app) 
开发者ID:vmagamedov,项目名称:hiku,代码行数:12,代码来源:graphql_aiohttp.py

示例10: __init__

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import post [as 别名]
def __init__(self, bot, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.pool = None

        with open("pyhtml/auth", 'r') as af:
            self.client_id, self.client_secret = json.loads(af.read())

        self.bot = bot
        self.session = aiohttp.ClientSession(loop=bot.loop)
        self.logger = logging.getLogger('currency-converter')
        self.logger.setLevel(logging.INFO)
        self.handler = logging.FileHandler(filename="transactions.log",
                                           encoding='utf-8',
                                           mode='a')
        self.handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
        self.logger.addHandler(self.handler)

        with open("pyhtml/register.html") as _rf:
            self.register_html = _rf.read()

        with open("pyhtml/hub.html") as _rf:
            self.hub_html = _rf.read()

        with open("pyhtml/guild.html") as _rf:
            self.guild_html = _rf.read()

        self.add_routes([
            web.get('/code', self.code),
            web.get('/hub', self.hub),
            web.get('/guilds', self.guilds),
            web.get('/authorize', self.mydata),
            web.get('/', self.index),
            web.get('/register', self.register),
            web.get('/add/', self.add),
            web.get('/bots/{snowflake:\d+}/', self.convert),
            web.post('/bots/{snowflake:\d+}/', self.convert),
            web.get('/user/{guild:\d+}/{user:\d+}{tail:.*}', self.getuser),
            web.get('/guild/{guild:\d+}{tail:.*}', self.getguild),
        ]) 
开发者ID:henry232323,项目名称:RPGBot,代码行数:41,代码来源:server.py

示例11: get_application

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import post [as 别名]
def get_application(self):
        """
        Override the get_app method to return your application.
        """
        app = web.Application()
        app.add_routes([web.post("/topic/{topic}/", self.receive_hook)])
        return app 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:9,代码来源:test_admin_server.py

示例12: register

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

    app.add_routes(
        [
            web.post("/ledger/register-nym", register_ledger_nym),
            web.patch("/ledger/rotate-public-did-keypair", rotate_public_did_keypair),
            web.get("/ledger/did-verkey", get_did_verkey, allow_head=False),
            web.get("/ledger/did-endpoint", get_did_endpoint, allow_head=False),
            web.get("/ledger/taa", ledger_get_taa, allow_head=False),
            web.post("/ledger/taa/accept", ledger_accept_taa),
        ]
    ) 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:15,代码来源:routes.py

示例13: register

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import post [as 别名]
def register(app: web.Application):
    """Register routes."""
    app.add_routes(
        [
            web.post("/revocation/create-registry", revocation_create_registry),
            web.get(
                "/revocation/registries/created",
                revocation_registries_created,
                allow_head=False,
            ),
            web.get(
                "/revocation/registry/{rev_reg_id}", get_registry, allow_head=False
            ),
            web.get(
                "/revocation/active-registry/{cred_def_id}",
                get_active_registry,
                allow_head=False,
            ),
            web.get(
                "/revocation/registry/{rev_reg_id}/tails-file",
                get_tails_file,
                allow_head=False,
            ),
            web.patch("/revocation/registry/{rev_reg_id}", update_registry),
            web.post("/revocation/registry/{rev_reg_id}/publish", publish_registry),
        ]
    ) 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:29,代码来源:routes.py

示例14: register

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

    app.add_routes(
        [web.post("/connections/{conn_id}/send-message", connections_send_message)]
    ) 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:8,代码来源:routes.py

示例15: register

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

    app.add_routes(
        [web.post("/connections/{conn_id}/send-ping", connections_send_ping)]
    ) 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:8,代码来源:routes.py


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