File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 88from pywebio import start_server
99from pywebio .platform import config
1010from pywebio .session import local as session_local , info as session_info
11+ import pywebio_battery
1112
1213##########################################
1314# Pre-import modules for demo
@@ -30,7 +31,12 @@ def t(eng, chinese):
3031
3132
3233def playground (code ):
33- code = f"{ PRE_IMPORT } \n { code } "
34+ pre_import = PRE_IMPORT
35+ battery_apis = pywebio_battery .__all__
36+ if 'pywebio_battery import' not in code and any (api in code for api in battery_apis ):
37+ pre_import += 'from pywebio_battery import *\n '
38+
39+ code = f"{ pre_import } \n { code } "
3440 encode = base64 .b64encode (code .encode ('utf8' )).decode ('utf8' )
3541 url = f"{ playground_host } /#{ encode } "
3642 run_js ('window.open(url)' , url = url )
You can’t perform that action at this time.
0 commit comments