浏览代码

compatible with python 3.5.2

wangweimin 5 年之前
父节点
当前提交
e972c752c5
共有 3 个文件被更改,包括 8 次插入5 次删除
  1. 1 2
      pywebio/input.py
  2. 4 2
      pywebio/output.py
  3. 3 1
      pywebio/platform/flask.py

+ 1 - 2
pywebio/input.py

@@ -27,7 +27,6 @@
 import logging
 from base64 import b64decode
 from collections.abc import Mapping
-from typing import Coroutine
 
 from .io_ctrl import single_input, input_control
 
@@ -59,7 +58,7 @@ def _parse_args(kwargs):
 
 
 def input(label='', type=TEXT, *, valid_func=None, name=None, value=None, placeholder=None, required=None,
-          readonly=None, datalist=None, help_text=None, **other_html_attrs) -> Coroutine:
+          readonly=None, datalist=None, help_text=None, **other_html_attrs):
     r"""文本输入
 
     :param str label: 输入框标签

+ 4 - 2
pywebio/output.py

@@ -393,8 +393,10 @@ def put_image(content, format=None, title='', anchor=None, before=None, after=No
     format = '' if format is None else ('image/%s' % format)
 
     b64content = b64encode(content).decode('ascii')
-    put_html(f'<img src="data:{format};base64, {b64content}" alt="{title}" />',
-             anchor=anchor, before=before, after=after)
+    html = r'<img src="data:{format};base64, {b64content}" alt="{title}" />'.format(format=format,
+                                                                                    b64content=b64content,
+                                                                                    title=title)
+    put_html(html, anchor=anchor, before=before, after=after)
 
 
 def put_file(name, content, anchor=None, before=None, after=None):

+ 3 - 1
pywebio/platform/flask.py

@@ -34,7 +34,9 @@ from ..utils import STATIC_PATH
 from ..utils import random_str, LRUDict
 
 # todo: use lock to avoid thread race condition
-_webio_sessions: Dict[str, AbstractSession] = {}  # WebIOSessionID -> WebIOSession()
+
+# type: Dict[str, AbstractSession]
+_webio_sessions = {}  # WebIOSessionID -> WebIOSession()
 _webio_expire = LRUDict()  # WebIOSessionID -> last active timestamp
 
 DEFAULT_SESSION_EXPIRE_SECONDS = 60  # 超过60s会话不活跃则视为会话过期