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


Python web.HTTPOk方法代码示例

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


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

示例1: _test_transport

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import HTTPOk [as 别名]
def _test_transport(make_route, make_request):
    route = make_route()
    request = make_request(
        "GET", "/sm/", match_info={"transport": "xhr", "session": "s1", "server": "000"}
    )

    params = []

    class Transport:
        def __init__(self, manager, session, request):
            params.append((manager, session, request))

        def process(self):
            return web.HTTPOk()

    route = make_route(handlers={"test": (True, Transport)})
    res = await route.handler(request)
    assert isinstance(res, web.HTTPOk)
    assert params[0] == (route.manager, route.manager["s1"], request) 
开发者ID:aio-libs,项目名称:sockjs,代码行数:21,代码来源:test_route.py

示例2: liveness_probe

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import HTTPOk [as 别名]
def liveness_probe(self, request):
        if self.bot.is_ready():
            raise web.HTTPOk()

        raise web.HTTPNotAcceptable() 
开发者ID:Xenon-Bot,项目名称:xenon,代码行数:7,代码来源:api.py

示例3: test_raw_websocket

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import HTTPOk [as 别名]
def test_raw_websocket(make_route, make_request, mocker):
    ws = mocker.patch("sockjs.route.RawWebSocketTransport")
    loop = asyncio.get_event_loop()
    ws.return_value.process.return_value = loop.create_future()
    ws.return_value.process.return_value.set_result(web.HTTPOk())

    route = make_route()
    request = make_request("GET", "/sm/", headers=CIMultiDict({}))
    res = await route.websocket(request)

    assert isinstance(res, web.HTTPOk)
    assert ws.called
    assert ws.return_value.process.called 
开发者ID:aio-libs,项目名称:sockjs,代码行数:15,代码来源:test_route.py

示例4: receive_hook

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import HTTPOk [as 别名]
def receive_hook(self, request):
        topic = request.match_info["topic"]
        payload = await request.json()
        self.hook_results.append((topic, payload))
        raise web.HTTPOk() 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:7,代码来源:test_admin_server.py

示例5: receive_message

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import HTTPOk [as 别名]
def receive_message(self, request):
        payload = await request.json()
        self.message_results.append(payload)
        raise web.HTTPOk() 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:6,代码来源:test_http_transport.py

示例6: binary

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import HTTPOk [as 别名]
def binary(app, handler):
    async def middleware_handler(request):
        response = await handler(request)
        if isinstance(response, (bytes, bytearray, memoryview)):
            return web.HTTPOk(body=response)
        elif isinstance(response, str):
            return web.HTTPOk(text=response)
        else:
            return response
    return middleware_handler 
开发者ID:aamalev,项目名称:aiohttp_apiset,代码行数:12,代码来源:middlewares.py

示例7: test_get

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import HTTPOk [as 别名]
def test_get(view, mocker, prefix):
    m = mocker.Mock()
    m.method = 'GET'
    m.path = ''
    m.match_info = {}
    with pytest.raises(web.HTTPOk):
        await view.factory(prefix=prefix)().get() 
开发者ID:aamalev,项目名称:aiohttp_apiset,代码行数:9,代码来源:test_view.py

示例8: handler

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import HTTPOk [as 别名]
def handler(request):
    return web.HTTPOk() 
开发者ID:aamalev,项目名称:aiohttp_apiset,代码行数:4,代码来源:test_dispatcher.py

示例9: handler

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import HTTPOk [as 别名]
def handler(request):
    """
    ---
    description: swagger operation
    """
    raise web.HTTPOk() 
开发者ID:aamalev,项目名称:aiohttp_apiset,代码行数:8,代码来源:conftest.py

示例10: get

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import HTTPOk [as 别名]
def get(self, request):
        raise web.HTTPOk(text='simple handler get') 
开发者ID:aamalev,项目名称:aiohttp_apiset,代码行数:4,代码来源:conftest.py

示例11: callback

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import HTTPOk [as 别名]
def callback(self, request: web.Request):
        """Route for handling HTTP callback"""
        request_json = await request.json()
        hash = request_json['hash']
        self.logger.debug(f"callback received {hash}")
        # cache
        if not await RedisDB.instance().exists(f"callback:{hash}"):
            await RedisDB.instance().set(f"callback:{hash}", "val", expires=300)
        else:
            return web.HTTPOk()
        # De-serialize block
        request_json['block'] = json.loads(request_json['block'])
        # only consider sends
        if 'is_send' in request_json and (request_json['is_send'] or request_json['is_send'] == 'true'):
            if 'amount' in request_json:
                # only consider self.min_amount or larger
                converted_amount = Env.raw_to_amount(int(request_json['amount']))
                if converted_amount >= self.min_amount:
                    # Figure out of this is one of our users
                    link = request_json['block']['link_as_account']
                    account = await Account.filter(address=link).prefetch_related('user').first()
                    if account is None:
                        return web.HTTPOk()
                    # See if this is an internal TX
                    transaction = await Transaction.filter(block_hash=hash).prefetch_related('receiving_user').first()
                    if transaction is not None and transaction.receiving_user is not None:
                        return web.HTTPOk()
                    self.logger.debug(f'Deposit received: {request_json["amount"]} for {account.user.id}')
                    amount_string = f"{Env.raw_to_amount(int(request_json['amount']))} {Env.currency_symbol()}"
                    discord_user = await self.bot.fetch_user(account.user.id)
                    if discord_user is not None:
                        await Messages.send_success_dm(discord_user, f"Your deposit of **{amount_string}** has been received. It will be in your available balance shortly!", header="Deposit Success", footer=f"I only notify you of deposits that are {self.min_amount} {Env.currency_symbol()} or greater.")
        return web.HTTPOk() 
开发者ID:bbedward,项目名称:graham_discord_bot,代码行数:35,代码来源:server.py

示例12: response_file

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import HTTPOk [as 别名]
def response_file(url, mime_type, filename=None):
    headers = {'X-Accel-Redirect': url}
    if filename:
        v = 'attachment; filename="{}"'.format(filename)
        headers['Content-Disposition'] = v
    raise web.HTTPOk(
        content_type=mime_type,
        headers=headers,
    ) 
开发者ID:dvhb,项目名称:dvhb-hybrid,代码行数:11,代码来源:aviews.py

示例13: http200

# 需要导入模块: from aiohttp import web [as 别名]
# 或者: from aiohttp.web import HTTPOk [as 别名]
def http200(request):
    raise web.HTTPOk(body=b'') 
开发者ID:dvhb,项目名称:dvhb-hybrid,代码行数:4,代码来源:aviews.py


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