ソースを参照

main: refine `pywebio.platform`

wangweimin 4 年 前
コミット
114035d16a

+ 186 - 150
docs/locales/zh_CN/LC_MESSAGES/platform.po

@@ -7,15 +7,16 @@ msgid ""
 msgstr ""
 msgstr ""
 "Project-Id-Version: PyWebIO 1.1.0\n"
 "Project-Id-Version: PyWebIO 1.1.0\n"
 "Report-Msgid-Bugs-To: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-02-17 17:57+0800\n"
-"PO-Revision-Date: 2021-02-18 11:28+0800\n"
+"POT-Creation-Date: 2021-03-11 18:32+0800\n"
+"PO-Revision-Date: 2021-03-11 18:37+0800\n"
+"Last-Translator: WangWeimin <wang0.618@qq.com>\n"
+"Language: zh_CN\n"
+"Language-Team: \n"
+"Plural-Forms: nplurals=1; plural=0;\n"
 "MIME-Version: 1.0\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=utf-8\n"
 "Content-Type: text/plain; charset=utf-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Generated-By: Babel 2.8.0\n"
 "Generated-By: Babel 2.8.0\n"
-"Last-Translator: WangWeimin <wang0.618@qq.com>\n"
-"Language-Team: \n"
-"Language: zh_CN\n"
 "X-Generator: Poedit 2.4.2\n"
 "X-Generator: Poedit 2.4.2\n"
 
 
 #: ../../platform.rst:2
 #: ../../platform.rst:2
@@ -30,16 +31,14 @@ msgstr "``platform`` 模块为PyWebIO提供了对不同Web框架的支持。"
 msgid ""
 msgid ""
 "See also: :ref:`Integration with Web Framework <integration_web_framework>` "
 "See also: :ref:`Integration with Web Framework <integration_web_framework>` "
 "section of user manual."
 "section of user manual."
-msgstr ""
-"具体用法参见用户手册 :ref:`与Web框架集成 <integration_web_framework>` 小节"
+msgstr "具体用法参见用户手册 :ref:`与Web框架集成 <integration_web_framework>` 小节"
 
 
 #: of pywebio.platform:6
 #: of pywebio.platform:6
 msgid "Tornado support"
 msgid "Tornado support"
 msgstr "Tornado相关"
 msgstr "Tornado相关"
 
 
 #: of pywebio.platform.tornado.start_server:1
 #: of pywebio.platform.tornado.start_server:1
-msgid ""
-"Start a Tornado server to provide the PyWebIO application as a web service."
+msgid "Start a Tornado server to provide the PyWebIO application as a web service."
 msgstr "启动一个 Tornado server 将PyWebIO应用作为Web服务提供。"
 msgstr "启动一个 Tornado server 将PyWebIO应用作为Web服务提供。"
 
 
 #: of pywebio.platform.tornado.start_server:3
 #: of pywebio.platform.tornado.start_server:3
@@ -63,77 +62,74 @@ msgstr ""
 msgid ""
 msgid ""
 "PyWebIO application. Can be a task function, a list of functions, or a "
 "PyWebIO application. Can be a task function, a list of functions, or a "
 "dictionary.  When it is a dictionary, whose key is task name and value is task "
 "dictionary.  When it is a dictionary, whose key is task name and value is task "
-"function. When it is a list, using function name as task name.  You can select "
-"the task to run through the ``app`` URL parameter (for example, visit ``http://"
-"host:port/?app=foo`` to run the ``foo`` task), By default, the ``index`` task "
-"function is used. When the ``index`` task does not exist, PyWebIO will provide "
-"a default index home page. See also :ref:`Server mode "
-"<server_and_script_mode>`  When the task function is a coroutine function, use :"
-"ref:`Coroutine-based session <coroutine_based_session>` implementation, "
-"otherwise, use thread-based session implementation."
+"function. When it is a list, using function name as task name.  You can select the "
+"task to run through the ``app`` URL parameter (for example, visit ``http://host:"
+"port/?app=foo`` to run the ``foo`` task), By default, the ``index`` task function "
+"is used. When the ``index`` task does not exist, PyWebIO will provide a default "
+"index home page. See also :ref:`Server mode <server_and_script_mode>`  When the "
+"task function is a coroutine function, use :ref:`Coroutine-based session "
+"<coroutine_based_session>` implementation, otherwise, use thread-based session "
+"implementation."
 msgstr ""
 msgstr ""
 
 
 #: of pywebio.platform.tornado.start_server:6
 #: of pywebio.platform.tornado.start_server:6
 msgid ""
 msgid ""
-"PyWebIO application. Can be a task function, a list of functions, or a "
-"dictionary."
+"PyWebIO application. Can be a task function, a list of functions, or a dictionary."
 msgstr "PyWebIO应用. 可以是任务函数或者任务函数的字典或列表。"
 msgstr "PyWebIO应用. 可以是任务函数或者任务函数的字典或列表。"
 
 
 #: of pywebio.platform.tornado.start_server:9
 #: of pywebio.platform.tornado.start_server:9
 msgid ""
 msgid ""
-"When it is a dictionary, whose key is task name and value is task function. "
-"When it is a list, using function name as task name."
+"When it is a dictionary, whose key is task name and value is task function. When "
+"it is a list, using function name as task name."
 msgstr "类型为字典时,字典键为任务名,类型为列表时,函数名为任务名。"
 msgstr "类型为字典时,字典键为任务名,类型为列表时,函数名为任务名。"
 
 
 #: of pywebio.platform.tornado.start_server:12
 #: of pywebio.platform.tornado.start_server:12
 msgid ""
 msgid ""
 "You can select the task to run through the ``app`` URL parameter (for example, "
 "You can select the task to run through the ``app`` URL parameter (for example, "
 "visit ``http://host:port/?app=foo`` to run the ``foo`` task), By default, the "
 "visit ``http://host:port/?app=foo`` to run the ``foo`` task), By default, the "
-"``index`` task function is used. When the ``index`` task does not exist, "
-"PyWebIO will provide a default index home page. See also :ref:`Server mode "
+"``index`` task function is used. When the ``index`` task does not exist, PyWebIO "
+"will provide a default index home page. See also :ref:`Server mode "
 "<server_and_script_mode>`"
 "<server_and_script_mode>`"
 msgstr ""
 msgstr ""
-"可以通过 ``app`` URL参数选择要运行的任务(例如访问 ``http://host:port/?app=foo`` "
-"运行 ``foo`` 任务),\n"
-"默认使用运行 ``index`` 任务函数,当 ``index`` 任务不存在时,PyWebIO会提供一个默"
-"认的索引页作为主页。\n"
+"可以通过 ``app`` URL参数选择要运行的任务(例如访问 ``http://host:port/?app=foo`` "
+"运行 ``foo`` 任务),\n"
+"默认使用运行 ``index`` 任务函数,当 ``index`` 任务不存在时,PyWebIO会提供一个默认的"
+"索引页作为主页。\n"
 "参见 :ref:`Server模式 <server_and_script_mode>`"
 "参见 :ref:`Server模式 <server_and_script_mode>`"
 
 
 #: of pywebio.platform.tornado.start_server:16
 #: of pywebio.platform.tornado.start_server:16
 msgid ""
 msgid ""
-"When the task function is a coroutine function, use :ref:`Coroutine-based "
-"session <coroutine_based_session>` implementation, otherwise, use thread-based "
-"session implementation."
+"When the task function is a coroutine function, use :ref:`Coroutine-based session "
+"<coroutine_based_session>` implementation, otherwise, use thread-based session "
+"implementation."
 msgstr ""
 msgstr ""
-"任务函数为协程函数时,使用 :ref:`基于协程的会话实现 <coroutine_based_session>` "
-";任务函数为普通函数时,使用基于线程的会话实现。"
+"任务函数为协程函数时,使用 :ref:`基于协程的会话实现 <coroutine_based_session>` ;任"
+"务函数为普通函数时,使用基于线程的会话实现。"
 
 
-#: of pywebio.platform.aiohttp.start_server:5
-#: pywebio.platform.django.start_server:5 pywebio.platform.flask.start_server:5
-#: pywebio.platform.tornado.start_server:18
+#: of pywebio.platform.aiohttp.start_server:5 pywebio.platform.django.start_server:5
+#: pywebio.platform.flask.start_server:5 pywebio.platform.tornado.start_server:18
 msgid ""
 msgid ""
-"The port the server listens on. When set to ``0``, the server will "
-"automatically select a available port."
+"The port the server listens on. When set to ``0``, the server will automatically "
+"select a available port."
 msgstr "服务监听的端口。设置为 ``0`` 时,表示自动选择可用端口。"
 msgstr "服务监听的端口。设置为 ``0`` 时,表示自动选择可用端口。"
 
 
-#: of pywebio.platform.aiohttp.start_server:7
-#: pywebio.platform.django.start_server:7 pywebio.platform.flask.start_server:7
-#: pywebio.platform.tornado.start_server:20
+#: of pywebio.platform.aiohttp.start_server:7 pywebio.platform.django.start_server:7
+#: pywebio.platform.flask.start_server:7 pywebio.platform.tornado.start_server:20
 msgid ""
 msgid ""
-"The host the server listens on. ``host`` may be either an IP address or "
-"hostname. If it’s a hostname, the server will listen on all IP addresses "
-"associated with the name. ``host`` may be an empty string or None to listen on "
-"all available interfaces."
+"The host the server listens on. ``host`` may be either an IP address or hostname. "
+"If it’s a hostname, the server will listen on all IP addresses associated with the "
+"name. ``host`` may be an empty string or None to listen on all available "
+"interfaces."
 msgstr ""
 msgstr ""
-"服务绑定的地址。 ``host`` 可以是IP地址或者为hostname。如果为hostname,服务会监听"
-"有与该hostname关联的IP地址。\n"
+"服务绑定的地址。 ``host`` 可以是IP地址或者为hostname。如果为hostname,服务会监听"
+"有与该hostname关联的IP地址。\n"
 "通过设置 ``host`` 为空字符串或 ``None`` 来将服务绑定到所有可用的地址上。"
 "通过设置 ``host`` 为空字符串或 ``None`` 来将服务绑定到所有可用的地址上。"
 
 
 #: of pywebio.platform.tornado.start_server:21
 #: of pywebio.platform.tornado.start_server:21
 msgid ""
 msgid ""
-"Tornado Server's debug mode. If enabled, the server will automatically reload "
-"for code changes. See `tornado doc <https://www.tornadoweb.org/en/stable/guide/"
-"running.html#debug-mode>`_ for more detail."
+"Tornado Server's debug mode. If enabled, the server will automatically reload for "
+"code changes. See `tornado doc <https://www.tornadoweb.org/en/stable/guide/running."
+"html#debug-mode>`_ for more detail."
 msgstr ""
 msgstr ""
 "是否开启Tornado Server的debug模式,开启后,代码发生修改后服务器会自动重启。\n"
 "是否开启Tornado Server的debug模式,开启后,代码发生修改后服务器会自动重启。\n"
 "详情请参阅 `tornado 文档 <https://www.tornadoweb.org/en/stable/guide/running."
 "详情请参阅 `tornado 文档 <https://www.tornadoweb.org/en/stable/guide/running."
@@ -144,31 +140,30 @@ msgstr ""
 #: pywebio.platform.django.webio_view:5 pywebio.platform.flask.start_server:8
 #: pywebio.platform.django.webio_view:5 pywebio.platform.flask.start_server:8
 #: pywebio.platform.flask.webio_view:5 pywebio.platform.tornado.start_server:23
 #: pywebio.platform.flask.webio_view:5 pywebio.platform.tornado.start_server:23
 msgid ""
 msgid ""
-"Whether to load front-end static resources from CDN, the default is ``True``. "
-"Can also use a string to directly set the url of PyWebIO static resources."
+"Whether to load front-end static resources from CDN, the default is ``True``. Can "
+"also use a string to directly set the url of PyWebIO static resources."
 msgstr ""
 msgstr ""
-"是否从CDN加载前端静态资源,默认为 ``True`` 。支持传入自定义的URL来指定静态资源的"
-"署地址"
+"是否从CDN加载前端静态资源,默认为 ``True`` 。支持传入自定义的URL来指定静态资源的"
+"署地址"
 
 
 #: of pywebio.platform.tornado.start_server:25
 #: of pywebio.platform.tornado.start_server:25
 msgid ""
 msgid ""
-"The allowed request source list. (The current server host is always allowed) "
-"The source contains the protocol, domain name, and port part. Can use Unix "
-"shell-style wildcards:   - ``*`` matches everything  - ``?`` matches any single "
-"character  - ``[seq]`` matches any character in *seq*  - ``[!seq]`` matches any "
-"character not in *seq*   Such as: ``https://*.example.com`` 、 ``*://*.example."
-"com``   For detail, see `Python Doc <https://docs.python.org/zh-tw/3/library/"
-"fnmatch.html>`_"
+"The allowed request source list. (The current server host is always allowed) The "
+"source contains the protocol, domain name, and port part. Can use Unix shell-style "
+"wildcards:   - ``*`` matches everything  - ``?`` matches any single character  - "
+"``[seq]`` matches any character in *seq*  - ``[!seq]`` matches any character not "
+"in *seq*   Such as: ``https://*.example.com`` 、 ``*://*.example.com``   For "
+"detail, see `Python Doc <https://docs.python.org/zh-tw/3/library/fnmatch.html>`_"
 msgstr ""
 msgstr ""
 
 
 #: of pywebio.platform.tornado.start_server:25
 #: of pywebio.platform.tornado.start_server:25
 msgid ""
 msgid ""
-"The allowed request source list. (The current server host is always allowed) "
-"The source contains the protocol, domain name, and port part. Can use Unix "
-"shell-style wildcards:"
+"The allowed request source list. (The current server host is always allowed) The "
+"source contains the protocol, domain name, and port part. Can use Unix shell-style "
+"wildcards:"
 msgstr ""
 msgstr ""
-"除当前域名外,服务器还允许的请求的来源列表。来源包含协议、域名和端口部分,允许使"
-"Unix shell 风格的匹配模式:"
+"除当前域名外,服务器还允许的请求的来源列表。来源包含协议、域名和端口部分,允许使"
+"Unix shell 风格的匹配模式:"
 
 
 #: of pywebio.platform.tornado.start_server:29
 #: of pywebio.platform.tornado.start_server:29
 msgid "``*`` matches everything"
 msgid "``*`` matches everything"
@@ -195,15 +190,14 @@ msgid ""
 "For detail, see `Python Doc <https://docs.python.org/zh-tw/3/library/fnmatch."
 "For detail, see `Python Doc <https://docs.python.org/zh-tw/3/library/fnmatch."
 "html>`_"
 "html>`_"
 msgstr ""
 msgstr ""
-"全部规则参见 `Python文档 <https://docs.python.org/zh-tw/3/library/fnmatch."
-"html>`_ "
+"全部规则参见 `Python文档 <https://docs.python.org/zh-tw/3/library/fnmatch.html>`_ "
 
 
 #: of pywebio.platform.tornado.start_server:37
 #: of pywebio.platform.tornado.start_server:37
 msgid ""
 msgid ""
-"The validation function for request source. It receives the source string "
-"(which contains protocol, host, and port parts) as parameter and return ``True/"
-"False`` to indicate that the server accepts/rejects the request. If "
-"``check_origin`` is set, the ``allowed_origins`` parameter will be ignored."
+"The validation function for request source. It receives the source string (which "
+"contains protocol, host, and port parts) as parameter and return ``True/False`` to "
+"indicate that the server accepts/rejects the request. If ``check_origin`` is set, "
+"the ``allowed_origins`` parameter will be ignored."
 msgstr ""
 msgstr ""
 "请求来源检查函数。接收请求来源(包含协议、域名和端口部分)字符串作为参数,\n"
 "请求来源检查函数。接收请求来源(包含协议、域名和端口部分)字符串作为参数,\n"
 "返回 ``True/False`` 指示服务器接受/拒绝该请求。若设置了 ``check_origin`` , "
 "返回 ``True/False`` 指示服务器接受/拒绝该请求。若设置了 ``check_origin`` , "
@@ -224,34 +218,34 @@ msgstr "Tornado Server最大可接受的WebSockets消息大小。单位为字节
 
 
 #: of pywebio.platform.tornado.start_server:43
 #: of pywebio.platform.tornado.start_server:43
 msgid ""
 msgid ""
-"If set to a number, all websockets will be pinged every n seconds. This can "
-"help keep the connection alive through certain proxy servers which close idle "
-"connections, and it can detect if the websocket has failed without being "
-"properly closed."
+"If set to a number, all websockets will be pinged every n seconds. This can help "
+"keep the connection alive through certain proxy servers which close idle "
+"connections, and it can detect if the websocket has failed without being properly "
+"closed."
 msgstr ""
 msgstr ""
-"当被设置后,服务器会以 ``websocket_ping_interval`` 秒周期性地向每个WebSockets连"
-"接发送'ping'消息。\n"
+"当被设置后,服务器会以 ``websocket_ping_interval`` 秒周期性地向每个WebSockets连接发"
+"送'ping'消息。\n"
 "如果应用处在某些反向代理服务器之后,设置 ``websocket_ping_interval`` 可以避免"
 "如果应用处在某些反向代理服务器之后,设置 ``websocket_ping_interval`` 可以避免"
 "WebSockets连接被代理服务器当作空闲连接而关闭。\n"
 "WebSockets连接被代理服务器当作空闲连接而关闭。\n"
 "同时,若WebSockets连接在某些情况下被异常关闭,应用也可以及时感知。"
 "同时,若WebSockets连接在某些情况下被异常关闭,应用也可以及时感知。"
 
 
 #: of pywebio.platform.tornado.start_server:46
 #: of pywebio.platform.tornado.start_server:46
 msgid ""
 msgid ""
-"If the ping interval is set, and the server doesn’t receive a ‘pong’ in this "
-"many seconds, it will close the websocket. The default is three times the ping "
-"interval, with a minimum of 30 seconds. Ignored if ``websocket_ping_interval`` "
-"is not set."
+"If the ping interval is set, and the server doesn’t receive a ‘pong’ in this many "
+"seconds, it will close the websocket. The default is three times the ping "
+"interval, with a minimum of 30 seconds. Ignored if ``websocket_ping_interval`` is "
+"not set."
 msgstr ""
 msgstr ""
 "如果设置了 ``websocket_ping_interval`` ,而服务没有在发送'ping'消息后的 "
 "如果设置了 ``websocket_ping_interval`` ,而服务没有在发送'ping'消息后的 "
 "``websocket_ping_timeout`` 秒\n"
 "``websocket_ping_timeout`` 秒\n"
-"内收到'pong'消息,应用会将连接关闭。默认的超时时间为 "
-"``websocket_ping_interval`` 的三倍。"
+"内收到'pong'消息,应用会将连接关闭。默认的超时时间为 ``websocket_ping_interval`` 的"
+"三倍。"
 
 
 #: of pywebio.platform.tornado.start_server:49
 #: of pywebio.platform.tornado.start_server:49
 msgid ""
 msgid ""
 "Additional keyword arguments passed to the constructor of ``tornado.web."
 "Additional keyword arguments passed to the constructor of ``tornado.web."
-"Application``. For details, please refer: https://www.tornadoweb.org/en/stable/"
-"web.html#tornado.web.Application.settings"
+"Application``. For details, please refer: https://www.tornadoweb.org/en/stable/web."
+"html#tornado.web.Application.settings"
 msgstr ""
 msgstr ""
 "传递给 ``tornado.web.Application`` 构造函数的额外的关键字参数\n"
 "传递给 ``tornado.web.Application`` 构造函数的额外的关键字参数\n"
 "可设置项参考: https://www.tornadoweb.org/en/stable/web.html#tornado.web."
 "可设置项参考: https://www.tornadoweb.org/en/stable/web.html#tornado.web."
@@ -259,50 +253,63 @@ msgstr ""
 
 
 #: of pywebio.platform.tornado.webio_handler:1
 #: of pywebio.platform.tornado.webio_handler:1
 msgid ""
 msgid ""
-"Get the ``RequestHandler`` class for running PyWebIO applications in Tornado. "
-"The ``RequestHandler`` communicates with the browser by WebSocket protocol."
+"Get the ``RequestHandler`` class for running PyWebIO applications in Tornado. The "
+"``RequestHandler`` communicates with the browser by WebSocket protocol."
 msgstr ""
 msgstr ""
-"获取在Tornado中运行PyWebIO应用的RequestHandler类。RequestHandler类基于WebSocket"
-"协议与浏览器进行通讯。"
+"获取在Tornado中运行PyWebIO应用的RequestHandler类。RequestHandler类基于WebSocket协议"
+"与浏览器进行通讯。"
 
 
 #: of pywebio.platform.tornado.webio_handler:4
 #: of pywebio.platform.tornado.webio_handler:4
 msgid ""
 msgid ""
-"The arguments of ``webio_handler()`` have the same meaning as for :func:"
-"`pywebio.platform.tornado.start_server`"
+"The arguments of ``webio_handler()`` have the same meaning as for :func:`pywebio."
+"platform.tornado.start_server`"
 msgstr ""
 msgstr ""
-"关于各参数的详细说明见 :func:`pywebio.platform.tornado.start_server` 的同名参"
-"数。"
+"关于各参数的详细说明见 :func:`pywebio.platform.tornado.start_server` 的同名参数。"
 
 
 #: of pywebio.platform:11
 #: of pywebio.platform:11
 msgid "Flask support"
 msgid "Flask support"
 msgstr ""
 msgstr ""
 
 
+#: of pywebio.platform:13
+msgid ""
+"When using the Flask as PyWebIO backend server, you need to install Flask by "
+"yourself and make sure the version is not less than ``0.10``. You can install it "
+"with the following command::"
+msgstr ""
+"使用Flask后端作为PyWebIO应用Server时,需要您自行安装Flask,并确保版本大于等于 "
+"``0.10`` 。\n"
+"可通过以下命令安装::"
+
+#: of pywebio.platform:16
+msgid "pip3 install -U flask>=0.10"
+msgstr ""
+
 #: of pywebio.platform.flask.webio_view:1
 #: of pywebio.platform.flask.webio_view:1
 msgid ""
 msgid ""
 "Get the view function for running PyWebIO applications in Flask. The view "
 "Get the view function for running PyWebIO applications in Flask. The view "
 "communicates with the browser by HTTP protocol."
 "communicates with the browser by HTTP protocol."
 msgstr "获取在Flask中运行PyWebIO任务的视图函数。基于http请求与前端页面进行通讯"
 msgstr "获取在Flask中运行PyWebIO任务的视图函数。基于http请求与前端页面进行通讯"
 
 
-#: of pywebio.platform.aiohttp.webio_handler:4
-#: pywebio.platform.django.webio_view:4 pywebio.platform.flask.webio_view:4
+#: of pywebio.platform.aiohttp.webio_handler:4 pywebio.platform.django.webio_view:4
+#: pywebio.platform.flask.webio_view:4
 msgid "PyWebIO application."
 msgid "PyWebIO application."
 msgstr "PyWebIO应用"
 msgstr "PyWebIO应用"
 
 
 #: of pywebio.platform.django.webio_view:7 pywebio.platform.flask.webio_view:7
 #: of pywebio.platform.django.webio_view:7 pywebio.platform.flask.webio_view:7
-msgid "Session expiration time."
-msgstr "会话过期时间。"
+msgid "Session expiration time, in seconds(default 60s)."
+msgstr "会话过期时间,单位为秒(默认60秒)。"
 
 
 #: of pywebio.platform.django.webio_view:8 pywebio.platform.flask.webio_view:8
 #: of pywebio.platform.django.webio_view:8 pywebio.platform.flask.webio_view:8
-msgid "Session cleanup interval, in seconds."
-msgstr "会话清理间隔(秒)。"
+msgid "Session cleanup interval, in seconds(default 120s)."
+msgstr "会话清理间隔,单位为秒(默认120秒)。"
 
 
-#: of pywebio.platform.aiohttp.webio_handler:7
-#: pywebio.platform.django.webio_view:9 pywebio.platform.flask.webio_view:9
+#: of pywebio.platform.aiohttp.webio_handler:7 pywebio.platform.django.webio_view:9
+#: pywebio.platform.flask.webio_view:9
 msgid "Allowed request source list."
 msgid "Allowed request source list."
 msgstr "除当前域名外,服务器还允许的请求的来源列表。"
 msgstr "除当前域名外,服务器还允许的请求的来源列表。"
 
 
-#: of pywebio.platform.aiohttp.webio_handler:8
-#: pywebio.platform.django.webio_view:10 pywebio.platform.flask.webio_view:10
+#: of pywebio.platform.aiohttp.webio_handler:8 pywebio.platform.django.webio_view:10
+#: pywebio.platform.flask.webio_view:10
 msgid "The validation function for request source."
 msgid "The validation function for request source."
 msgstr "请求来源检查函数"
 msgstr "请求来源检查函数"
 
 
@@ -317,8 +324,8 @@ msgstr ""
 msgid "Start a Flask server to provide the PyWebIO application as a web service."
 msgid "Start a Flask server to provide the PyWebIO application as a web service."
 msgstr "启动一个 Flask server 将PyWebIO应用作为Web服务提供。"
 msgstr "启动一个 Flask server 将PyWebIO应用作为Web服务提供。"
 
 
-#: of pywebio.platform.aiohttp.start_server:3
-#: pywebio.platform.django.start_server:3 pywebio.platform.flask.start_server:3
+#: of pywebio.platform.aiohttp.start_server:3 pywebio.platform.django.start_server:3
+#: pywebio.platform.flask.start_server:3
 msgid ""
 msgid ""
 "PyWebIO application. The argument has the same meaning and format as for :func:"
 "PyWebIO application. The argument has the same meaning and format as for :func:"
 "`pywebio.platform.tornado.start_server`"
 "`pywebio.platform.tornado.start_server`"
@@ -332,33 +339,33 @@ msgid ""
 "Allowed request source list. The argument has the same meaning as for :func:"
 "Allowed request source list. The argument has the same meaning as for :func:"
 "`pywebio.platform.tornado.start_server`"
 "`pywebio.platform.tornado.start_server`"
 msgstr ""
 msgstr ""
-"除当前域名外,服务器还允许的请求的来源列表。格式同 :func:`pywebio.platform."
-"tornado.start_server` 的 ``allowed_origins`` 参数"
+"除当前域名外,服务器还允许的请求的来源列表。格式同 :func:`pywebio.platform.tornado."
+"start_server` 的 ``allowed_origins`` 参数"
 
 
 #: of pywebio.platform.aiohttp.start_server:13
 #: of pywebio.platform.aiohttp.start_server:13
 #: pywebio.platform.django.start_server:12 pywebio.platform.flask.start_server:12
 #: pywebio.platform.django.start_server:12 pywebio.platform.flask.start_server:12
 msgid ""
 msgid ""
-"The validation function for request source. The argument has the same meaning "
-"and format as for :func:`pywebio.platform.tornado.start_server`"
+"The validation function for request source. The argument has the same meaning and "
+"format as for :func:`pywebio.platform.tornado.start_server`"
 msgstr ""
 msgstr ""
 "请求来源检查函数。格式同 :func:`pywebio.platform.tornado.start_server` 的 "
 "请求来源检查函数。格式同 :func:`pywebio.platform.tornado.start_server` 的 "
 "``check_origin`` 参数"
 "``check_origin`` 参数"
 
 
-#: of pywebio.platform.django.start_server:14
-#: pywebio.platform.flask.start_server:14
+#: of pywebio.platform.django.start_server:14 pywebio.platform.flask.start_server:14
 msgid ""
 msgid ""
-"Session expiration time. If no client message is received within "
-"``session_expire_seconds``, the session will be considered expired."
+"Session expiration time, in seconds(default 60s). If no client message is received "
+"within ``session_expire_seconds``, the session will be considered expired."
 msgstr ""
 msgstr ""
-"会话过期时间。若 session_expire_seconds 秒内没有收到客户端的请求,则认为会话过"
-"期。"
+"会话过期时间,单位为秒(默认60秒)。若 session_expire_seconds 秒内没有收到客户端的"
+"请求,则认为会话过期。"
 
 
-#: of pywebio.platform.django.start_server:16
-#: pywebio.platform.flask.start_server:16
+#: of pywebio.platform.django.start_server:16 pywebio.platform.flask.start_server:16
 msgid ""
 msgid ""
-"Session cleanup interval, in seconds. The server will periodically clean up "
-"expired sessions and release the resources occupied by the sessions."
-msgstr "会话清理间隔(秒)。服务端会周期性清理过期的会话,释放会话占用的资源。"
+"Session cleanup interval, in seconds(default 120s). The server will periodically "
+"clean up expired sessions and release the resources occupied by the sessions."
+msgstr ""
+"会话清理间隔,单位为秒(默认12秒)。服务端会周期性清理过期的会话,释放会话占用的资"
+"源。"
 
 
 #: of pywebio.platform.flask.start_server:18
 #: of pywebio.platform.flask.start_server:18
 msgid ""
 msgid ""
@@ -374,10 +381,24 @@ msgstr ""
 "传递给 ``flask.Flask.run`` 函数的额外的关键字参数\n"
 "传递给 ``flask.Flask.run`` 函数的额外的关键字参数\n"
 "可设置项参考: https://flask.palletsprojects.com/en/1.1.x/api/#flask.Flask.run"
 "可设置项参考: https://flask.palletsprojects.com/en/1.1.x/api/#flask.Flask.run"
 
 
-#: of pywebio.platform:16
+#: of pywebio.platform:23
 msgid "Django support"
 msgid "Django support"
 msgstr ""
 msgstr ""
 
 
+#: of pywebio.platform:25
+msgid ""
+"When using the Django as PyWebIO backend server, you need to install Django by "
+"yourself and make sure the version is not less than ``2.2``. You can install it "
+"with the following command::"
+msgstr ""
+"使用Django后端作为PyWebIO应用Server时,需要您自行安装Django,并确保版本大于等于 "
+"``2.2`` 。\n"
+"可通过以下命令安装::"
+
+#: of pywebio.platform:28
+msgid "pip3 install -U django>=2.2"
+msgstr ""
+
 #: of pywebio.platform.django.webio_view:1
 #: of pywebio.platform.django.webio_view:1
 msgid ""
 msgid ""
 "Get the view function for running PyWebIO applications in Django. The view "
 "Get the view function for running PyWebIO applications in Django. The view "
@@ -406,42 +427,56 @@ msgstr ""
 #: of pywebio.platform.django.start_server:20
 #: of pywebio.platform.django.start_server:20
 msgid ""
 msgid ""
 "Additional settings to django server. For details, please refer: https://docs."
 "Additional settings to django server. For details, please refer: https://docs."
-"djangoproject.com/en/3.0/ref/settings/ . Among them, ``DEBUG``, "
-"``ALLOWED_HOSTS``, ``ROOT_URLCONF``, ``SECRET_KEY`` are set by PyWebIO and "
-"cannot be specified in ``django_options``."
+"djangoproject.com/en/3.0/ref/settings/ . Among them, ``DEBUG``, ``ALLOWED_HOSTS``, "
+"``ROOT_URLCONF``, ``SECRET_KEY`` are set by PyWebIO and cannot be specified in "
+"``django_options``."
 msgstr ""
 msgstr ""
 "django应用的其他设置,见 https://docs.djangoproject.com/en/3.0/ref/settings/ .\n"
 "django应用的其他设置,见 https://docs.djangoproject.com/en/3.0/ref/settings/ .\n"
-"其中 ``DEBUG`` 、 ``ALLOWED_HOSTS`` 、 ``ROOT_URLCONF`` 、 ``SECRET_KEY`` 被"
-"PyWebIO设置,无法在 ``django_options`` 中指定"
+"其中 ``DEBUG`` 、 ``ALLOWED_HOSTS`` 、 ``ROOT_URLCONF`` 、 ``SECRET_KEY`` 被PyWebIO"
+"设置,无法在 ``django_options`` 中指定"
 
 
-#: of pywebio.platform:21
+#: of pywebio.platform:34
 msgid "aiohttp support"
 msgid "aiohttp support"
 msgstr ""
 msgstr ""
 
 
+#: of pywebio.platform:36
+msgid ""
+"When using the aiohttp as PyWebIO backend server, you need to install aiohttp by "
+"yourself and make sure the version is not less than ``3.1``. You can install it "
+"with the following command::"
+msgstr ""
+"使用aiohttp后端作为PyWebIO应用Server时,需要您自行安装aiohttp,并确保版本大于等于 "
+"``3.1`` 。\n"
+"可通过以下命令安装::"
+
+#: of pywebio.platform:39
+msgid "pip3 install -U aiohttp>=3.1"
+msgstr ""
+
 #: of pywebio.platform.aiohttp.webio_handler:1
 #: of pywebio.platform.aiohttp.webio_handler:1
 msgid ""
 msgid ""
 "Get the `Request Handler <https://docs.aiohttp.org/en/stable/web_quickstart."
 "Get the `Request Handler <https://docs.aiohttp.org/en/stable/web_quickstart."
-"html#aiohttp-web-handler>`_ coroutine for running PyWebIO applications in "
-"aiohttp. The handler communicates with the browser by WebSocket protocol."
+"html#aiohttp-web-handler>`_ coroutine for running PyWebIO applications in aiohttp. "
+"The handler communicates with the browser by WebSocket protocol."
 msgstr ""
 msgstr ""
-"获取在aiohttp中运行PyWebIO任务函数的 `Request Handler <https://docs.aiohttp.org/"
-"en/stable/web_quickstart.html#aiohttp-web-handler>`_ 协程。Request Handler基于"
+"获取在aiohttp中运行PyWebIO任务函数的 `Request Handler <https://docs.aiohttp.org/en/"
+"stable/web_quickstart.html#aiohttp-web-handler>`_ 协程。Request Handler基于"
 "WebSocket协议与浏览器进行通讯。"
 "WebSocket协议与浏览器进行通讯。"
 
 
 #: of pywebio.platform.aiohttp.webio_handler:9
 #: of pywebio.platform.aiohttp.webio_handler:9
 msgid ""
 msgid ""
 "The  parameters passed to the constructor of ``aiohttp.web.WebSocketResponse``."
 "The  parameters passed to the constructor of ``aiohttp.web.WebSocketResponse``."
 msgstr ""
 msgstr ""
-"创建 aiohttp WebSocketResponse 时使用的参数。见 https://docs.aiohttp.org/en/"
-"stable/web_reference.html#websocketresponse"
+"创建 aiohttp WebSocketResponse 时使用的参数。见 https://docs.aiohttp.org/en/stable/"
+"web_reference.html#websocketresponse"
 
 
 #: of pywebio.platform.aiohttp.webio_handler:11
 #: of pywebio.platform.aiohttp.webio_handler:11
 msgid ""
 msgid ""
-"The arguments of ``webio_handler()`` have the same meaning as for :func:"
-"`pywebio.platform.aiohttp.start_server`"
+"The arguments of ``webio_handler()`` have the same meaning as for :func:`pywebio."
+"platform.aiohttp.start_server`"
 msgstr ""
 msgstr ""
-"关于 ``applications`` 、 ``allowed_origins`` 、 ``check_origin`` 参数的详细说明"
-"见 :func:`pywebio.platform.aiohttp.start_server` 的同名参数。"
+"关于 ``applications`` 、 ``allowed_origins`` 、 ``check_origin`` 参数的详细说明见 :"
+"func:`pywebio.platform.aiohttp.start_server` 的同名参数。"
 
 
 #: of pywebio.platform.aiohttp.webio_handler
 #: of pywebio.platform.aiohttp.webio_handler
 msgid "Returns"
 msgid "Returns"
@@ -452,8 +487,7 @@ msgid "aiohttp Request Handler"
 msgstr ""
 msgstr ""
 
 
 #: of pywebio.platform.aiohttp.start_server:1
 #: of pywebio.platform.aiohttp.start_server:1
-msgid ""
-"Start a aiohttp server to provide the PyWebIO application as a web service."
+msgid "Start a aiohttp server to provide the PyWebIO application as a web service."
 msgstr "启动一个 aiohttp server 将PyWebIO应用作为Web服务提供。"
 msgstr "启动一个 aiohttp server 将PyWebIO应用作为Web服务提供。"
 
 
 #: of pywebio.platform.aiohttp.start_server:8
 #: of pywebio.platform.aiohttp.start_server:8
@@ -466,8 +500,8 @@ msgid ""
 "For details, please refer: https://docs.aiohttp.org/en/stable/web_reference."
 "For details, please refer: https://docs.aiohttp.org/en/stable/web_reference."
 "html#websocketresponse"
 "html#websocketresponse"
 msgstr ""
 msgstr ""
-"创建 aiohttp WebSocketResponse 时使用的参数。见 https://docs.aiohttp.org/en/"
-"stable/web_reference.html#websocketresponse"
+"创建 aiohttp WebSocketResponse 时使用的参数。见 https://docs.aiohttp.org/en/stable/"
+"web_reference.html#websocketresponse"
 
 
 #: of pywebio.platform.aiohttp.start_server:18
 #: of pywebio.platform.aiohttp.start_server:18
 msgid ""
 msgid ""
@@ -475,17 +509,17 @@ msgid ""
 "Application``. For details, please refer: https://docs.aiohttp.org/en/stable/"
 "Application``. For details, please refer: https://docs.aiohttp.org/en/stable/"
 "web_reference.html#application"
 "web_reference.html#application"
 msgstr ""
 msgstr ""
-"需要传给 aiohttp Application 的参数。可用参数见 https://docs.aiohttp.org/en/"
-"stable/web_reference.html#application"
+"需要传给 aiohttp Application 的参数。可用参数见 https://docs.aiohttp.org/en/stable/"
+"web_reference.html#application"
 
 
-#: of pywebio.platform:26
+#: of pywebio.platform:45
 msgid "Other"
 msgid "Other"
 msgstr "其他"
 msgstr "其他"
 
 
 #: of pywebio.platform.seo:1
 #: of pywebio.platform.seo:1
 msgid ""
 msgid ""
-"Set the SEO information of the PyWebIO application (web page information "
-"provided when indexed by search engines)"
+"Set the SEO information of the PyWebIO application (web page information provided "
+"when indexed by search engines)"
 msgstr "设置PyWebIO应用的SEO信息(在被搜索引擎索引时提供的网页信息)"
 msgstr "设置PyWebIO应用的SEO信息(在被搜索引擎索引时提供的网页信息)"
 
 
 #: of pywebio.platform.seo:3
 #: of pywebio.platform.seo:3
@@ -503,8 +537,7 @@ msgstr "PyWebIO任务函数"
 #: of pywebio.platform.seo:7
 #: of pywebio.platform.seo:7
 msgid ""
 msgid ""
 "If not ``seo()`` is not used, the `docstring <https://www.python.org/dev/peps/"
 "If not ``seo()`` is not used, the `docstring <https://www.python.org/dev/peps/"
-"pep-0257/>`_ of the task function will be regarded as SEO information by "
-"default."
+"pep-0257/>`_ of the task function will be regarded as SEO information by default."
 msgstr "除了使用 ``seo()`` 函数,PyWebIO默认会将任务函数的函数注释作为SEO信息::"
 msgstr "除了使用 ``seo()`` 函数,PyWebIO默认会将任务函数的函数注释作为SEO信息::"
 
 
 #: of pywebio.platform.seo:9
 #: of pywebio.platform.seo:9
@@ -565,6 +598,9 @@ msgstr ""
 
 
 #: of pywebio.platform.run_event_loop:5
 #: of pywebio.platform.run_event_loop:5
 msgid ""
 msgid ""
-"Set the debug mode of the event loop. See also: https://docs.python.org/3/"
-"library/asyncio-dev.html#asyncio-debug-mode"
+"Set the debug mode of the event loop. See also: https://docs.python.org/3/library/"
+"asyncio-dev.html#asyncio-debug-mode"
 msgstr ""
 msgstr ""
+
+#~ msgid "Session cleanup interval, in seconds(default 20s)."
+#~ msgstr "会话清理间隔(秒)。"

+ 19 - 0
pywebio/platform/__init__.py

@@ -10,16 +10,35 @@ Tornado support
 
 
 Flask support
 Flask support
 -----------------
 -----------------
+
+When using the Flask as PyWebIO backend server, you need to install Flask by yourself and make sure the version is not less than ``0.10``.
+You can install it with the following command::
+
+    pip3 install -U flask>=0.10
+
+
 .. autofunction:: pywebio.platform.flask.webio_view
 .. autofunction:: pywebio.platform.flask.webio_view
 .. autofunction:: pywebio.platform.flask.start_server
 .. autofunction:: pywebio.platform.flask.start_server
 
 
 Django support
 Django support
 -----------------
 -----------------
+
+When using the Django as PyWebIO backend server, you need to install Django by yourself and make sure the version is not less than ``2.2``.
+You can install it with the following command::
+
+    pip3 install -U django>=2.2
+
 .. autofunction:: pywebio.platform.django.webio_view
 .. autofunction:: pywebio.platform.django.webio_view
 .. autofunction:: pywebio.platform.django.start_server
 .. autofunction:: pywebio.platform.django.start_server
 
 
 aiohttp support
 aiohttp support
 -----------------
 -----------------
+
+When using the aiohttp as PyWebIO backend server, you need to install aiohttp by yourself and make sure the version is not less than ``3.1``.
+You can install it with the following command::
+
+    pip3 install -U aiohttp>=3.1
+
 .. autofunction:: pywebio.platform.aiohttp.webio_handler
 .. autofunction:: pywebio.platform.aiohttp.webio_handler
 .. autofunction:: pywebio.platform.aiohttp.start_server
 .. autofunction:: pywebio.platform.aiohttp.start_server
 
 

+ 5 - 4
pywebio/platform/django.py

@@ -82,8 +82,8 @@ def webio_view(applications, cdn=True,
     :param list/dict/callable applications: PyWebIO application.
     :param list/dict/callable applications: PyWebIO application.
     :param bool/str cdn: Whether to load front-end static resources from CDN, the default is ``True``.
     :param bool/str cdn: Whether to load front-end static resources from CDN, the default is ``True``.
        Can also use a string to directly set the url of PyWebIO static resources.
        Can also use a string to directly set the url of PyWebIO static resources.
-    :param int session_expire_seconds: Session expiration time.
-    :param int session_cleanup_interval: Session cleanup interval, in seconds.
+    :param int session_expire_seconds: Session expiration time, in seconds(default 600s).
+    :param int session_cleanup_interval: Session cleanup interval, in seconds(default 300s).
     :param list allowed_origins: Allowed request source list.
     :param list allowed_origins: Allowed request source list.
     :param callable check_origin: The validation function for request source.
     :param callable check_origin: The validation function for request source.
 
 
@@ -96,6 +96,7 @@ def webio_view(applications, cdn=True,
                           allowed_origins=allowed_origins, check_origin=check_origin)
                           allowed_origins=allowed_origins, check_origin=check_origin)
 
 
     from django.views.decorators.csrf import csrf_exempt
     from django.views.decorators.csrf import csrf_exempt
+
     @csrf_exempt
     @csrf_exempt
     def view_func(request):
     def view_func(request):
         context = DjangoHttpContext(request)
         context = DjangoHttpContext(request)
@@ -126,9 +127,9 @@ def start_server(applications, port=8080, host='localhost', cdn=True,
        The argument has the same meaning as for :func:`pywebio.platform.tornado.start_server`
        The argument has the same meaning as for :func:`pywebio.platform.tornado.start_server`
     :param callable check_origin: The validation function for request source.
     :param callable check_origin: The validation function for request source.
        The argument has the same meaning and format as for :func:`pywebio.platform.tornado.start_server`
        The argument has the same meaning and format as for :func:`pywebio.platform.tornado.start_server`
-    :param int session_expire_seconds: Session expiration time.
+    :param int session_expire_seconds: Session expiration time, in seconds(default 600s).
        If no client message is received within ``session_expire_seconds``, the session will be considered expired.
        If no client message is received within ``session_expire_seconds``, the session will be considered expired.
-    :param int session_cleanup_interval: Session cleanup interval, in seconds.
+    :param int session_cleanup_interval: Session cleanup interval, in seconds(default 300s).
        The server will periodically clean up expired sessions and release the resources occupied by the sessions.
        The server will periodically clean up expired sessions and release the resources occupied by the sessions.
     :param bool debug: Django debug mode.
     :param bool debug: Django debug mode.
        See `Django doc <https://docs.djangoproject.com/en/3.0/ref/settings/#debug>`_ for more detail.
        See `Django doc <https://docs.djangoproject.com/en/3.0/ref/settings/#debug>`_ for more detail.

+ 4 - 4
pywebio/platform/flask.py

@@ -85,8 +85,8 @@ def webio_view(applications, cdn=True,
     :param list/dict/callable applications: PyWebIO application.
     :param list/dict/callable applications: PyWebIO application.
     :param bool/str cdn: Whether to load front-end static resources from CDN, the default is ``True``.
     :param bool/str cdn: Whether to load front-end static resources from CDN, the default is ``True``.
        Can also use a string to directly set the url of PyWebIO static resources.
        Can also use a string to directly set the url of PyWebIO static resources.
-    :param int session_expire_seconds: Session expiration time.
-    :param int session_cleanup_interval: Session cleanup interval, in seconds.
+    :param int session_expire_seconds: Session expiration time, in seconds(default 600s).
+    :param int session_cleanup_interval: Session cleanup interval, in seconds(default 300s).
     :param list allowed_origins: Allowed request source list.
     :param list allowed_origins: Allowed request source list.
     :param callable check_origin: The validation function for request source.
     :param callable check_origin: The validation function for request source.
 
 
@@ -126,9 +126,9 @@ def start_server(applications, port=8080, host='localhost', cdn=True,
        The argument has the same meaning as for :func:`pywebio.platform.tornado.start_server`
        The argument has the same meaning as for :func:`pywebio.platform.tornado.start_server`
     :param callable check_origin: The validation function for request source.
     :param callable check_origin: The validation function for request source.
        The argument has the same meaning and format as for :func:`pywebio.platform.tornado.start_server`
        The argument has the same meaning and format as for :func:`pywebio.platform.tornado.start_server`
-    :param int session_expire_seconds: Session expiration time.
+    :param int session_expire_seconds: Session expiration time, in seconds(default 600s).
        If no client message is received within ``session_expire_seconds``, the session will be considered expired.
        If no client message is received within ``session_expire_seconds``, the session will be considered expired.
-    :param int session_cleanup_interval: Session cleanup interval, in seconds.
+    :param int session_cleanup_interval: Session cleanup interval, in seconds(default 300s).
        The server will periodically clean up expired sessions and release the resources occupied by the sessions.
        The server will periodically clean up expired sessions and release the resources occupied by the sessions.
     :param bool debug: Flask debug mode.
     :param bool debug: Flask debug mode.
        If enabled, the server will automatically reload for code changes.
        If enabled, the server will automatically reload for code changes.

+ 4 - 4
pywebio/platform/httpbased.py

@@ -37,7 +37,7 @@ class HttpContext:
         Return the HTTP method of the current request, uppercase"""
         Return the HTTP method of the current request, uppercase"""
         pass
         pass
 
 
-    def request_headers(self):
+    def request_headers(self) -> dict:
         """返回当前请求的header字典
         """返回当前请求的header字典
         Return the header dictionary of the current request"""
         Return the header dictionary of the current request"""
         pass
         pass
@@ -105,8 +105,8 @@ class HttpHandler:
     # After processing the POST request, wait for WAIT_MS_ON_POST milliseconds before generate response
     # After processing the POST request, wait for WAIT_MS_ON_POST milliseconds before generate response
     WAIT_MS_ON_POST = 100
     WAIT_MS_ON_POST = 100
 
 
-    DEFAULT_SESSION_EXPIRE_SECONDS = 60  # Default session expiration time
-    DEFAULT_SESSIONS_CLEANUP_INTERVAL = 20  # Default interval for clearing expired sessions (in seconds)
+    DEFAULT_SESSION_EXPIRE_SECONDS = 600  # Default session expiration time
+    DEFAULT_SESSIONS_CLEANUP_INTERVAL = 300  # Default interval for clearing expired sessions (in seconds)
 
 
     @classmethod
     @classmethod
     def _remove_expired_sessions(cls, session_expire_seconds):
     def _remove_expired_sessions(cls, session_expire_seconds):
@@ -261,7 +261,7 @@ class HttpHandler:
         if check_origin is None:
         if check_origin is None:
             self.check_origin = lambda origin: any(
             self.check_origin = lambda origin: any(
                 fnmatch.fnmatch(origin, patten)
                 fnmatch.fnmatch(origin, patten)
-                for patten in allowed_origins or []
+                for patten in (allowed_origins or [])
             )
             )
 
 
 
 

+ 23 - 14
pywebio/platform/tornado.py

@@ -25,6 +25,11 @@ logger = logging.getLogger(__name__)
 _ioloop = None
 _ioloop = None
 
 
 
 
+def set_ioloop(loop):
+    global _ioloop
+    _ioloop = loop
+
+
 def ioloop() -> tornado.ioloop.IOLoop:
 def ioloop() -> tornado.ioloop.IOLoop:
     """获得运行Tornado server的IOLoop
     """获得运行Tornado server的IOLoop
 
 
@@ -55,7 +60,7 @@ def _is_same_site(origin, handler: WebSocketHandler):
     return origin == host
     return origin == host
 
 
 
 
-def _webio_handler(applications, cdn, check_origin_func=_is_same_site):
+def _webio_handler(applications=None, cdn=True, check_origin_func=_is_same_site):
     """
     """
     :param dict applications: dict of `name -> task function`
     :param dict applications: dict of `name -> task function`
     :param bool/str cdn: Whether to load front-end static resources from CDN
     :param bool/str cdn: Whether to load front-end static resources from CDN
@@ -64,17 +69,25 @@ def _webio_handler(applications, cdn, check_origin_func=_is_same_site):
     """
     """
     check_webio_js()
     check_webio_js()
 
 
+    if applications is None:
+        applications = dict(index=lambda: None)  # mock PyWebIO app
+
     class WSHandler(WebSocketHandler):
     class WSHandler(WebSocketHandler):
 
 
+        def get_app(self):
+            app_name = self.get_query_argument('app', 'index')
+            app = applications.get(app_name) or applications['index']
+            return app
+
         async def get(self, *args, **kwargs) -> None:
         async def get(self, *args, **kwargs) -> None:
             # It's a simple http GET request
             # It's a simple http GET request
             if self.request.headers.get("Upgrade", "").lower() != "websocket":
             if self.request.headers.get("Upgrade", "").lower() != "websocket":
                 # Backward compatible
                 # Backward compatible
+                # Frontend detect whether the backend is http server
                 if self.get_query_argument('test', ''):
                 if self.get_query_argument('test', ''):
                     return self.write('')
                     return self.write('')
 
 
-                app_name = self.get_query_argument('app', 'index')
-                app = applications.get(app_name) or applications['index']
+                app = self.get_app()
                 html = render_page(app, protocol='ws', cdn=cdn)
                 html = render_page(app, protocol='ws', cdn=cdn)
                 return self.write(html)
                 return self.write(html)
             else:
             else:
@@ -104,8 +117,7 @@ def _webio_handler(applications, cdn, check_origin_func=_is_same_site):
             session_info['request'] = self.request
             session_info['request'] = self.request
             session_info['backend'] = 'tornado'
             session_info['backend'] = 'tornado'
 
 
-            app_name = self.get_query_argument('app', 'index')
-            application = applications.get(app_name) or applications['index']
+            application = self.get_app()
             if iscoroutinefunction(application) or isgeneratorfunction(application):
             if iscoroutinefunction(application) or isgeneratorfunction(application):
                 self.session = CoroutineBasedSession(application, session_info=session_info,
                 self.session = CoroutineBasedSession(application, session_info=session_info,
                                                      on_task_command=self.send_msg_to_client,
                                                      on_task_command=self.send_msg_to_client,
@@ -145,7 +157,7 @@ def webio_handler(applications, cdn=True, allowed_origins=None, check_origin=Non
     for target in applications.values():
     for target in applications.values():
         register_session_implement_for_target(target)
         register_session_implement_for_target(target)
 
 
-    cdn = cdn_validation(cdn, 'error')
+    cdn = cdn_validation(cdn, 'error')  # if CDN is not available, raise error
 
 
     if check_origin is None:
     if check_origin is None:
         check_origin_func = partial(_check_origin, allowed_origins=allowed_origins or [])
         check_origin_func = partial(_check_origin, allowed_origins=allowed_origins or [])
@@ -237,15 +249,15 @@ def start_server(applications, port=0, host='',
         For details, please refer: https://www.tornadoweb.org/en/stable/web.html#tornado.web.Application.settings
         For details, please refer: https://www.tornadoweb.org/en/stable/web.html#tornado.web.Application.settings
     """
     """
     kwargs = locals()
     kwargs = locals()
-    global _ioloop
-    _ioloop = tornado.ioloop.IOLoop.current()
+
+    set_ioloop(tornado.ioloop.IOLoop.current())  # to enable bokeh app
 
 
     app_options = ['debug', 'websocket_max_message_size', 'websocket_ping_interval', 'websocket_ping_timeout']
     app_options = ['debug', 'websocket_max_message_size', 'websocket_ping_interval', 'websocket_ping_timeout']
     for opt in app_options:
     for opt in app_options:
         if kwargs[opt] is not None:
         if kwargs[opt] is not None:
             tornado_app_settings[opt] = kwargs[opt]
             tornado_app_settings[opt] = kwargs[opt]
 
 
-    cdn = cdn_validation(cdn, 'warn')
+    cdn = cdn_validation(cdn, 'warn')  # if CDN is not available, warn user and disable CDN
 
 
     handler = webio_handler(applications, cdn, allowed_origins=allowed_origins, check_origin=check_origin)
     handler = webio_handler(applications, cdn, allowed_origins=allowed_origins, check_origin=check_origin)
     _, port = _setup_server(webio_handler=handler, port=port, host=host, **tornado_app_settings)
     _, port = _setup_server(webio_handler=handler, port=port, host=host, **tornado_app_settings)
@@ -267,9 +279,7 @@ def start_server_in_current_thread_session():
     websocket_conn_opened = threading.Event()
     websocket_conn_opened = threading.Event()
     thread = threading.current_thread()
     thread = threading.current_thread()
 
 
-    mock_apps = dict(index=lambda: None)
-
-    class SingleSessionWSHandler(_webio_handler(applications=mock_apps, cdn=False)):
+    class SingleSessionWSHandler(_webio_handler(cdn=False)):
         session = None
         session = None
         instance = None
         instance = None
 
 
@@ -332,8 +342,7 @@ def start_server_in_current_thread_session():
         loop = asyncio.new_event_loop()
         loop = asyncio.new_event_loop()
         asyncio.set_event_loop(loop)
         asyncio.set_event_loop(loop)
 
 
-        global _ioloop
-        _ioloop = tornado.ioloop.IOLoop.current()
+        set_ioloop(tornado.ioloop.IOLoop.current())  # to enable bokeh app
 
 
         port = 0
         port = 0
         if os.environ.get("PYWEBIO_SCRIPT_MODE_PORT"):
         if os.environ.get("PYWEBIO_SCRIPT_MODE_PORT"):