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 8
8
from pywebio import start_server
9
9
from pywebio .platform import config
10
10
from pywebio .session import local as session_local , info as session_info
11
+ import pywebio_battery
11
12
12
13
##########################################
13
14
# Pre-import modules for demo
@@ -30,7 +31,12 @@ def t(eng, chinese):
30
31
31
32
32
33
def 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 } "
34
40
encode = base64 .b64encode (code .encode ('utf8' )).decode ('utf8' )
35
41
url = f"{ playground_host } /#{ encode } "
36
42
run_js ('window.open(url)' , url = url )
You can’t perform that action at this time.
0 commit comments