Handling external request

I don’t know if this is out of the scope of wave but is it possible to send requests from an external service to a wave app and have the wave app handling it correctly? For example, consider the following snippet:

from h2o_wave import site, ui, Q, main, app, on, handle_on

@app('/demo', mode='broadcast')
async def serve(q: Q):
    q.page['main'] = ui.markdown_card(
        box='1 1 -1 -1', title='Demo', content=f'Main page: [Make a request](#request)')
    if q.args['#'] == 'request':
        q.page['main'].content = 'Got request'
    await q.page.save()

Would it be possible from cURL for example to send a POST request to https://.../demo#request?


If I understand correctly, you’re asking for the ability for an external tool (like cURL) to impersonate a user and make a POST request to the waved web server, and have that request be passed on to the app as-is, so that it can update the UI. Is that correct?

This mechanism does not exist today, but it’s interesting, and I’m curious what problem you’re trying to solve here - maybe I can suggest alternatives, or put this on our roadmap.

Yes, that is what I was thinking of. I can give you my specific use case as an example: I have an external web app (grafana) that is sending me POST requests whenever I receive an alert on a value. I would like that POST request to go through the wave app to perform a simple calculation and update the UI of the wave app.

In general it could be interesting to have the possibility for a wave app to accept requests from external entities to allow inter-operation between services

Do you have any feedback or comment on this, @prithvi?

@Gianluca_Rigoletti - Yes, thanks for the example. I’ll post a issue in Github to track this. Should be possible to do along with this one, which is in a similar vein.

Tracked here: Allow apps to handle external HTTP requests · Issue #714 · h2oai/wave · GitHub

1 Like