Created
September 6, 2022 16:47
-
-
Save mturoci/d7a382e88ceb1043bd376e2b5f9c188b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from h2o_wave import main, app, Q, ui | |
@app('/') | |
async def serve(q: Q): | |
# Initialize the page with a single button. | |
if not q.client.initialized: | |
q.page['form'] = ui.form_card( | |
box='1 1 2 1', | |
items=[ | |
ui.button(name='start_recording', label='Start recording') | |
] | |
) | |
# Load JS polyfills to record on older browsers as well. | |
q.page['meta'] = ui.meta_card( | |
box='', | |
scripts=[ | |
ui.script('https://cdn.jsdelivr.net/npm/opus-media-recorder@latest/OpusMediaRecorder.umd.js', asynchronous=False), | |
ui.script('https://cdn.jsdelivr.net/npm/opus-media-recorder@latest/encoderWorker.umd.js', asynchronous=False), | |
] | |
) | |
# Load initial JS from file record_utils.js. | |
with open('record.js', encoding='utf-8') as f: | |
q.page['meta'].script = ui.inline_script(f.read()) | |
q.client.initialized = True | |
await q.page.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment