MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / download

Function download

pywebio/session/__init__.py:320–337  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

318
319
320def 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
340def run_js(code_, **args):

Callers 3

mainFunction · 0.90
mainFunction · 0.90
put_fileFunction · 0.85

Calls 1

send_msgFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…