Skip to main content

Mode / Unicast

Launch the server in unicast mode and use q.client to manage client-local state.

from h2o_wave import main, app, Q, ui

@app('/demo')async def serve(q: Q):    count = q.client.count or 0
    if not q.client.initialized:['example'] = ui.form_card(box='1 1 12 10', items=[            ui.button(name='increment', label=f'Count={count}')        ])        q.client.initialized = True
    if q.args.increment:        q.client.count = count = count + 1['example'].items[0].button.label = f'Count={count}'

Tags: โ€‚mode โ€‚unicast