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

Function handle_code

demos/doc_demo.py:106–127  ·  view source on GitHub ↗
(code, title)

Source from the content-addressed store, hash-verified

104
105
106def handle_code(code, title):
107 run_js(CLIPBOARD_SETUP)
108 session_local.globals = dict(globals())
109 if title:
110 put_markdown('## %s' % title)
111
112 for p in gen_snippets(code):
113 with use_scope() as scope:
114 put_code(p, 'python')
115
116 put_buttons(
117 [t('Run', '运行'),
118 t("Edit", '编辑'),
119 t("Copy to clipboard", '复制代码')],
120 onclick=[
121 partial(run_code, code=p, scope=scope),
122 partial(playground, code=p),
123 partial(copytoclipboard, code=p)
124 ]
125 )
126
127 put_markdown('----')
128
129
130def get_app():

Callers

nothing calls this directly

Calls 7

run_jsFunction · 0.85
put_markdownFunction · 0.85
gen_snippetsFunction · 0.85
use_scopeFunction · 0.85
put_codeFunction · 0.85
put_buttonsFunction · 0.85
tFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…