Send file to user, and the user browser will download the file to the local :param str name: File name when downloading :param content: File content. It is a bytes-like object Example: .. exportable-codeblock:: :name: download :summary: `download()` usage
(name, content)
| 318 | |
| 319 | |
| 320 | def download(name, content): |
| 321 | """Send file to user, and the user browser will download the file to the local |
| 322 | |
| 323 | :param str name: File name when downloading |
| 324 | :param content: File content. It is a bytes-like object |
| 325 | |
| 326 | Example: |
| 327 | |
| 328 | .. exportable-codeblock:: |
| 329 | :name: download |
| 330 | :summary: `download()` usage |
| 331 | |
| 332 | put_button('Click to download', lambda: download('hello-world.txt', b'hello world!')) |
| 333 | |
| 334 | """ |
| 335 | from ..io_ctrl import send_msg |
| 336 | content = b64encode(content).decode('ascii') |
| 337 | send_msg('download', spec=dict(name=name, content=content)) |
| 338 | |
| 339 | |
| 340 | def run_js(code_, **args): |