对于一个 BULK-OUT 命令 消息,可能会产生多个 BULK-IN 响应消息。
For example, the CCID can send a BULK-IN message with a Time Extension status to notify
the host that the ICC has requested more time to process the ICC command and, after a
delay, follow this with a second BULK-IN message with the ICC’s response to the
command. When this happens, both BULK-IN messages have the same bSeq value.
import asyncio
import httpx
from nicegui import ui
async def add(url):
print('----')
l = ui.label('This should be visible')
async with httpx.AsyncClient() as client:
r = await client.get(url)
res = r.json()
l.text = res['ip']
ip_url = 'https://api.seeip.org/jsonip'
#ip_url = 'https://api.ipify.org/?format=json'
ui.button('Add label', on_click= lambda:add(ip_url))
ui.run(reload=False, host="::", port=5678, favicon='🚀', title='httpx协程')
报错
RuntimeWarning: coroutine 'add' was never awaited
self.on('click', lambda _: handle_event(on_click, ClickEventArguments(sender=self, client=self.client)))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
修改成不带参数的
import asyncio
import httpx
from nicegui import ui
#ip_url = 'https://api.seeip.org/jsonip'
ip_url = 'https://api.bigdatacloud.net/data/client-ip'
async def add():
print('----')
l = ui.label('Waiting...')
async with httpx.AsyncClient() as client:
r = await client.get(ip_url)
res = r.json()
l.text = res['ipString']
ui.button('Get IP', on_click=add)
ui.run(reload=False, host="::", port=5678, favicon='🚀', title='httpx协程')