download_documentation.py 412 B

123456789101112131415
  1. from nicegui import ui
  2. from . import doc
  3. @doc.demo(ui.download)
  4. def main_demo() -> None:
  5. ui.button('Logo', on_click=lambda: ui.download('https://nicegui.io/logo.png'))
  6. @doc.demo('Download raw bytes from memory', '''
  7. The `download` function can also be used to download raw bytes from memory.
  8. ''')
  9. def raw_bytes():
  10. ui.button('Download', on_click=lambda: ui.download(b'Hello World', 'hello.txt'))