有没有通过javascript触发某消息函数的机制? #273
honesthnter
started this conversation in
Feature request
Replies: 2 comments 4 replies
|
使用底层的 from pywebio.output import *
from pywebio import session
from pywebio.io_ctrl import output_register_callback
def click_callback(val):
put_text(val)
callback_id = output_register_callback(click_callback)
session.run_js("WebIO.pushData('data', callback_id)", callback_id=callback_id)
|
1 reply
|
Hi Please can you give a little bit of example how this can be achieved using Coroutine-based session and start_server. In the above example the output_register_callback(click_callback) and session.runjs are both executed on the server side. How can one register the callback and pass the callback id to the client so it can be used in the client. I guess this can be done through the session. But can one use session when the server has not started? start_server will block until the window is closed, so I cannot place code after start_server |
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
有没有通过javascript触发某消息函数的机制?
All reactions