|
@@ -7,8 +7,8 @@ msgid ""
|
|
|
msgstr ""
|
|
|
"Project-Id-Version: PyWebIO 1.1.0\n"
|
|
|
"Report-Msgid-Bugs-To: \n"
|
|
|
-"POT-Creation-Date: 2021-06-11 21:51+0800\n"
|
|
|
-"PO-Revision-Date: 2021-06-11 21:53+0800\n"
|
|
|
+"POT-Creation-Date: 2021-07-20 22:58+0800\n"
|
|
|
+"PO-Revision-Date: 2021-07-20 23:02+0800\n"
|
|
|
"Last-Translator: WangWeimin <wang0.618@qq.com>\n"
|
|
|
"Language: zh_CN\n"
|
|
|
"Language-Team: \n"
|
|
@@ -17,7 +17,7 @@ msgstr ""
|
|
|
"Content-Type: text/plain; charset=utf-8\n"
|
|
|
"Content-Transfer-Encoding: 8bit\n"
|
|
|
"Generated-By: Babel 2.8.0\n"
|
|
|
-"X-Generator: Poedit 2.4.2\n"
|
|
|
+"X-Generator: Poedit 3.0\n"
|
|
|
|
|
|
#: ../../guide.rst:2
|
|
|
msgid "User's guide"
|
|
@@ -939,17 +939,17 @@ msgstr ""
|
|
|
msgid "Overview"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:620 ../../guide.rst:694
|
|
|
+#: ../../guide.rst:622 ../../guide.rst:696
|
|
|
msgid "**Server mode**"
|
|
|
msgstr "**Server模式**"
|
|
|
|
|
|
-#: ../../guide.rst:622
|
|
|
+#: ../../guide.rst:624
|
|
|
msgid ""
|
|
|
"In server mode, PyWebIO will start a web server to continuously provide services. When the user accesses the service address, PyWebIO will open a "
|
|
|
"new session and run PyWebIO application in it."
|
|
|
msgstr "在Server模式下,PyWebIO会启动一个Web服务来持续性地提供服务。当用户访问服务地址时,PyWebIO会开启一个新会话并运行PyWebIO应用。"
|
|
|
|
|
|
-#: ../../guide.rst:624
|
|
|
+#: ../../guide.rst:626
|
|
|
msgid ""
|
|
|
"Use `start_server() <pywebio.platform.tornado.start_server>` to start a web server and serve given PyWebIO applications on it. `start_server() "
|
|
|
"<pywebio.platform.tornado.start_server>` accepts a function as PyWebIO application. In addition, `start_server() <pywebio.platform.tornado."
|
|
@@ -961,7 +961,7 @@ msgstr ""
|
|
|
"也支持使用函数列表或字典,从而使一个PyWebIO Server下可以有多个不同功能的服务,服务之间可以通过 `go_app() <pywebio.session.go_app>` 或 `put_link() "
|
|
|
"<pywebio.output.put_link>` 进行跳转::"
|
|
|
|
|
|
-#: ../../guide.rst:626
|
|
|
+#: ../../guide.rst:628
|
|
|
msgid ""
|
|
|
"def task_1():\n"
|
|
|
" put_text('task_1')\n"
|
|
@@ -997,18 +997,19 @@ msgstr ""
|
|
|
"# 等价于 start_server({'index': index, 'task_1': task_1, 'task_2': task_2})\n"
|
|
|
"start_server([index, task_1, task_2])"
|
|
|
|
|
|
-#: ../../guide.rst:644
|
|
|
+#: ../../guide.rst:646
|
|
|
msgid ""
|
|
|
"The `start_server() <pywebio.platform.tornado.start_server>` provide a remote access support, when enabled (by passing `remote_access=True` to "
|
|
|
-"`start_server()`), you can get a temporary public network access address for the current application, others can access your application via this "
|
|
|
-"address. Using remote access makes it easy to temporarily share the application with others. This service is powered by `localhost.run <https://"
|
|
|
-"localhost.run>`_."
|
|
|
+"`start_server()`), you will get a public, shareable address for the current application, others can access your application in their browser via "
|
|
|
+"this address. Because the processing happens on your device (as long as your device stays on!), you don't have to worry about any dependencies. "
|
|
|
+"Using remote access makes it easy to temporarily share the application with others. This service is powered by `localhost.run <https://localhost."
|
|
|
+"run>`_."
|
|
|
msgstr ""
|
|
|
-"`start_server() <pywebio.platform.tornado.start_server>` 提供了远程访问的支持,当开启远程访问后(通过在 `start_server()` 中传入 "
|
|
|
-"`remote_access=True` 开启 ),你将会得到一个用于访问当前应用的临时的公网访问地址,其他人任何都可以使用此地址访问你的应用。远程接入可以很方便地将应用"
|
|
|
-"临时分享给其他人。当前远程接入功能由 `localhost.run <https://localhost.run>`_ 提供。"
|
|
|
+"`start_server() <pywebio.platform.tornado.start_server>` 提供了对远程访问的支持,当开启远程访问后(通过在 `start_server()` 中传入 "
|
|
|
+"`remote_access=True` 开启 ),你将会得到一个用于访问当前应用的临时的公网访问地址,其他任何人都可以使用此地址访问你的应用。远程接入可以很方便地将应用"
|
|
|
+"临时分享给其他人。当前远程接入功能由 `localhost.run <https://localhost.run>`_ 提供。"
|
|
|
|
|
|
-#: ../../guide.rst:646
|
|
|
+#: ../../guide.rst:648
|
|
|
msgid ""
|
|
|
"Use `path_deploy() <pywebio.platform.path_deploy>` to deploy the PyWebIO applications from a directory. The python file under this directory need "
|
|
|
"contain the ``main`` function to be seen as the PyWebIO application. You can access the application by using the file path as the URL."
|
|
@@ -1016,11 +1017,11 @@ msgstr ""
|
|
|
"使用 `path_deploy() <pywebio.platform.path_deploy>` 可以从一个路径中部署PyWebIO应用。位于该路径下的python文件需要包含名字为 ``main`` 的PyWebIO任务函"
|
|
|
"数才能被视为PyWebIO应用程序。服务端会根据用户访问的URL来确定需要加载的文件并从中读取PyWebIO应用来运行。"
|
|
|
|
|
|
-#: ../../guide.rst:650
|
|
|
+#: ../../guide.rst:652
|
|
|
msgid "For example, given the following folder structure::"
|
|
|
msgstr "例如,给定如下文件结构::"
|
|
|
|
|
|
-#: ../../guide.rst:652
|
|
|
+#: ../../guide.rst:654
|
|
|
msgid ""
|
|
|
".\n"
|
|
|
"├── A\n"
|
|
@@ -1030,7 +1031,7 @@ msgid ""
|
|
|
"└── c.py"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:659
|
|
|
+#: ../../guide.rst:661
|
|
|
msgid ""
|
|
|
"If you use this directory in `path_deploy() <pywebio.platform.path_deploy>`, you can access the PyWebIO application in ``b.py`` by using URL "
|
|
|
"``http://<host>:<port>/A/b``. And if the files have been modified after run `path_deploy() <pywebio.platform.path_deploy>`, you can use ``reload`` "
|
|
@@ -1040,7 +1041,7 @@ msgstr ""
|
|
|
"用。当文件在运行 `path_deploy() <pywebio.platform.path_deploy>` 之后被修改,可以使用 ``reload`` URL参数来重载文件: ``http://<host>:<port>/A/b?"
|
|
|
"reload``"
|
|
|
|
|
|
-#: ../../guide.rst:662
|
|
|
+#: ../../guide.rst:664
|
|
|
msgid ""
|
|
|
"You can also use the command ``pywebio-path-deploy`` to start a server just like using `path_deploy() <pywebio.platform.path_deploy>`. For more "
|
|
|
"information, refer ``pywebio-path-deploy --help``"
|
|
@@ -1048,7 +1049,7 @@ msgstr ""
|
|
|
"你还可以使用 ``pywebio-path-deploy`` 命令来启动一个和 `path_deploy() <pywebio.platform.path_deploy>` 效果一样的server。关于命令的更多信息请查阅命令"
|
|
|
"帮助: ``pywebio-path-deploy --help``"
|
|
|
|
|
|
-#: ../../guide.rst:664
|
|
|
+#: ../../guide.rst:666
|
|
|
msgid ""
|
|
|
"In Server mode, you can use `pywebio.platform.seo()` to set the `SEO <https://en.wikipedia.org/wiki/Search_engine_optimization>`_ information. If "
|
|
|
"``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 "
|
|
@@ -1057,13 +1058,13 @@ msgstr ""
|
|
|
"在Server模式下,可以使用 `pywebio.platform.seo()` 函数来设置任务函数SEO信息(在被搜索引擎索引时提供的网页信息,包含应用标题和应用简介),如果不使用 "
|
|
|
"``seo()`` 函数,默认条件下,PyWebIO会将任务函数的函数注释作为SEO信息(应用标题和简介之间使用一个空行分隔)。 "
|
|
|
|
|
|
-#: ../../guide.rst:668
|
|
|
+#: ../../guide.rst:670
|
|
|
msgid ""
|
|
|
"Note that in Server mode, all functions from ``input``, ``output`` and ``session`` modules can only be called in the context of task functions. For "
|
|
|
"example, the following code is **not allowed**::"
|
|
|
msgstr "注意,在Server模式下, ``input`` 、 ``output`` 和 ``session`` 模块内的函数仅能在任务函数上下文中进行调用。比如如下调用是 **不被允许的** ::"
|
|
|
|
|
|
-#: ../../guide.rst:670
|
|
|
+#: ../../guide.rst:672
|
|
|
msgid ""
|
|
|
"import pywebio\n"
|
|
|
"from pywebio.input import input\n"
|
|
@@ -1072,15 +1073,15 @@ msgid ""
|
|
|
"pywebio.start_server(my_task_func, port=int(port))"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:677 ../../guide.rst:690
|
|
|
+#: ../../guide.rst:679 ../../guide.rst:692
|
|
|
msgid "**Script mode**"
|
|
|
msgstr "**Script模式**"
|
|
|
|
|
|
-#: ../../guide.rst:679
|
|
|
+#: ../../guide.rst:681
|
|
|
msgid "In Script mode, PyWebIO input and output functions can be called anywhere."
|
|
|
msgstr "Script模式下,在任何位置都可以调用PyWebIO的交互函数。"
|
|
|
|
|
|
-#: ../../guide.rst:681
|
|
|
+#: ../../guide.rst:683
|
|
|
msgid ""
|
|
|
"If the user closes the browser before the end of the session, then calls to PyWebIO input and output functions in the session will cause a "
|
|
|
"`SessionException <pywebio.exceptions.SessionException>` exception."
|
|
@@ -1088,15 +1089,15 @@ msgstr ""
|
|
|
"如果用户在会话结束之前关闭了浏览器,那么之后会话内对于PyWebIO交互函数的调用将会引发一个 `SessionException <pywebio.exceptions.SessionException>` 异"
|
|
|
"常。"
|
|
|
|
|
|
-#: ../../guide.rst:686
|
|
|
+#: ../../guide.rst:688
|
|
|
msgid "Concurrent"
|
|
|
msgstr "并发"
|
|
|
|
|
|
-#: ../../guide.rst:688
|
|
|
+#: ../../guide.rst:690
|
|
|
msgid "PyWebIO can be used in a multi-threading environment."
|
|
|
msgstr "PyWebIO 支持在多线程环境中使用。"
|
|
|
|
|
|
-#: ../../guide.rst:692
|
|
|
+#: ../../guide.rst:694
|
|
|
msgid ""
|
|
|
"In Script mode, you can freely start new thread and call PyWebIO interactive functions in it. When all `non-daemonic <https://docs.python.org/3/"
|
|
|
"library/threading.html#thread-objects>`_ threads finish running, the script exits."
|
|
@@ -1104,7 +1105,7 @@ msgstr ""
|
|
|
"在 Script模式下,你可以自由地启动线程,并在其中调用PyWebIO的交互函数。当所有非 `Daemon线程 <https://docs.python.org/3/library/threading.html#thread-"
|
|
|
"objects>`_ 运行结束后,脚本退出。"
|
|
|
|
|
|
-#: ../../guide.rst:696
|
|
|
+#: ../../guide.rst:698
|
|
|
msgid ""
|
|
|
"In Server mode, if you need to use PyWebIO interactive functions in new thread, you need to use `register_thread(thread) <pywebio.session."
|
|
|
"register_thread>` to register the new thread (so that PyWebIO can know which session the thread belongs to). If the PyWebIO interactive function is "
|
|
@@ -1119,11 +1120,11 @@ msgstr ""
|
|
|
"理,其调用PyWebIO的交互函数将会产生 `SessionNotFoundException <pywebio.exceptions.SessionNotFoundException>` 异常。\n"
|
|
|
"当会话的任务函数和会话内通过 `register_thread(thread) <pywebio.session.register_thread>` 注册的线程都结束运行时,会话关闭。"
|
|
|
|
|
|
-#: ../../guide.rst:698
|
|
|
+#: ../../guide.rst:700
|
|
|
msgid "Example of using multi-threading in Server mode::"
|
|
|
msgstr "Server模式下多线程的使用示例::"
|
|
|
|
|
|
-#: ../../guide.rst:700
|
|
|
+#: ../../guide.rst:702
|
|
|
msgid ""
|
|
|
"def show_time():\n"
|
|
|
" while True:\n"
|
|
@@ -1146,11 +1147,11 @@ msgid ""
|
|
|
"start_server(app, port=8080, debug=True)"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:724 ../../guide.rst:1015
|
|
|
+#: ../../guide.rst:726 ../../guide.rst:1017
|
|
|
msgid "Close of session"
|
|
|
msgstr "会话的结束"
|
|
|
|
|
|
-#: ../../guide.rst:726
|
|
|
+#: ../../guide.rst:728
|
|
|
msgid ""
|
|
|
"The close of session may also be caused by the user closing the browser page. After the browser page is closed, PyWebIO input function calls that "
|
|
|
"have not yet returned in the current session will cause `SessionClosedException <pywebio.exceptions.SessionClosedException>`, and subsequent calls "
|
|
@@ -1161,7 +1162,7 @@ msgstr ""
|
|
|
"SessionClosedException>` 异常,之后对于PyWebIO交互函数的调用将会产生 `SessionNotFoundException <pywebio.exceptions.SessionNotFoundException>` 或 "
|
|
|
"`SessionClosedException <pywebio.exceptions.SessionClosedException>` 异常。"
|
|
|
|
|
|
-#: ../../guide.rst:728
|
|
|
+#: ../../guide.rst:730
|
|
|
msgid ""
|
|
|
"You can use `defer_call(func) <pywebio.session.defer_call>` to set the function to be called when the session closes. Whether it is because the "
|
|
|
"user closes the page or the task finishes to cause session closed, the function set by `defer_call(func) <pywebio.session.defer_call>` will be "
|
|
@@ -1173,11 +1174,11 @@ msgstr ""
|
|
|
"`defer_call(func) <pywebio.session.defer_call>` 可以用于资源清理等工作。在会话中可以多次调用 `defer_call() <pywebio.session.defer_call>` ,会话结束后"
|
|
|
"将会顺序执行设置的函数。"
|
|
|
|
|
|
-#: ../../guide.rst:733
|
|
|
+#: ../../guide.rst:735
|
|
|
msgid "Integration with web framework"
|
|
|
msgstr "与Web框架集成"
|
|
|
|
|
|
-#: ../../guide.rst:735
|
|
|
+#: ../../guide.rst:737
|
|
|
msgid ""
|
|
|
"The PyWebIO application can be integrated into an existing Python Web project, the PyWebIO application and the Web project share a web framework. "
|
|
|
"PyWebIO currently supports integration with Flask, Tornado, Django, aiohttp and FastAPI(Starlette) web frameworks."
|
|
@@ -1185,19 +1186,19 @@ msgstr ""
|
|
|
"可以将PyWebIO应用集成到现有的Python Web项目中,PyWebIO应用与Web项目共用一个Web框架。目前支持与Flask、Tornado、Django、aiohttp和FastAPI(Starlette) "
|
|
|
"Web框架的集成。"
|
|
|
|
|
|
-#: ../../guide.rst:737
|
|
|
+#: ../../guide.rst:739
|
|
|
msgid "The integration methods of those web frameworks are as follows:"
|
|
|
msgstr "不同Web框架的集成方法如下: "
|
|
|
|
|
|
-#: ../../guide.rst:741
|
|
|
+#: ../../guide.rst:743
|
|
|
msgid "Tornado"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:745
|
|
|
+#: ../../guide.rst:747
|
|
|
msgid "**Tornado**"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:747
|
|
|
+#: ../../guide.rst:749
|
|
|
msgid ""
|
|
|
"Use `pywebio.platform.tornado.webio_handler()` to get the `WebSocketHandler <https://www.tornadoweb.org/en/stable/websocket.html#tornado.websocket."
|
|
|
"WebSocketHandler>`_ class for running PyWebIO applications in Tornado::"
|
|
@@ -1205,7 +1206,7 @@ msgstr ""
|
|
|
"使用 `pywebio.platform.tornado.webio_handler()` 来获取在Tornado中运行PyWebIO应用的 `WebSocketHandler <https://www.tornadoweb.org/en/stable/"
|
|
|
"websocket.html#tornado.websocket.WebSocketHandler>`_ 类::"
|
|
|
|
|
|
-#: ../../guide.rst:749
|
|
|
+#: ../../guide.rst:751
|
|
|
msgid ""
|
|
|
"import tornado.ioloop\n"
|
|
|
"import tornado.web\n"
|
|
@@ -1224,13 +1225,13 @@ msgid ""
|
|
|
" tornado.ioloop.IOLoop.current().start()"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:766
|
|
|
+#: ../../guide.rst:768
|
|
|
msgid ""
|
|
|
"In above code, we add a routing rule to bind the ``WebSocketHandler`` of the PyWebIO application to the ``/tool`` path. After starting the Tornado "
|
|
|
"server, you can visit ``http://localhost/tool`` to open the PyWebIO application."
|
|
|
msgstr "以上代码将 PyWebIO 应用的 ``WebSocketHandler`` 绑定到了 ``/tool`` 路径下。 启动Tornado后,访问 ``http://localhost/tool``即可打开PyWebIO应用。"
|
|
|
|
|
|
-#: ../../guide.rst:771
|
|
|
+#: ../../guide.rst:773
|
|
|
msgid ""
|
|
|
"PyWebIO uses the WebSocket protocol to communicate with the browser in Tornado. If your Tornado application is behind a reverse proxy (such as "
|
|
|
"Nginx), you may need to configure the reverse proxy to support the WebSocket protocol. :ref:`Here <nginx_ws_config>` is an example of Nginx "
|
|
@@ -1239,19 +1240,19 @@ msgstr ""
|
|
|
"当使用Tornado后端时,PyWebIO使用WebSocket协议和浏览器进行通讯,如果你的Tornado应用处在反向代理(比如Nginx)之后,可能需要特别配置反向代理来支持"
|
|
|
"WebSocket协议,:ref:`这里 <nginx_ws_config>` 有一个Nginx配置WebSocket的例子。"
|
|
|
|
|
|
-#: ../../guide.rst:773
|
|
|
+#: ../../guide.rst:775
|
|
|
msgid "Flask"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:777
|
|
|
+#: ../../guide.rst:779
|
|
|
msgid "**Flask**"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:779
|
|
|
+#: ../../guide.rst:781
|
|
|
msgid "Use `pywebio.platform.flask.webio_view()` to get the view function for running PyWebIO applications in Flask::"
|
|
|
msgstr "使用 `pywebio.platform.flask.webio_view()` 来获取在Flask中运行PyWebIO应用的视图函数::"
|
|
|
|
|
|
-#: ../../guide.rst:781
|
|
|
+#: ../../guide.rst:783
|
|
|
msgid ""
|
|
|
"from pywebio.platform.flask import webio_view\n"
|
|
|
"from flask import Flask\n"
|
|
@@ -1265,7 +1266,7 @@ msgid ""
|
|
|
"app.run(host='localhost', port=80)"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:793
|
|
|
+#: ../../guide.rst:795
|
|
|
msgid ""
|
|
|
"In above code, we add a routing rule to bind the view function of the PyWebIO application to the ``/tool`` path. After starting the Flask "
|
|
|
"application, visit ``http://localhost/tool`` to open the PyWebIO application."
|
|
@@ -1273,19 +1274,19 @@ msgstr ""
|
|
|
"以上代码使用添加了一条路由规则将PyWebIO应用的视图函数绑定到 ``/tool`` 路径下。\n"
|
|
|
"启动Flask应用后,访问 ``http://localhost/tool`` 即可打开PyWebIO应用"
|
|
|
|
|
|
-#: ../../guide.rst:796
|
|
|
+#: ../../guide.rst:798
|
|
|
msgid "Django"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:800
|
|
|
+#: ../../guide.rst:802
|
|
|
msgid "**Django**"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:802
|
|
|
+#: ../../guide.rst:804
|
|
|
msgid "Use `pywebio.platform.django.webio_view()` to get the view function for running PyWebIO applications in Django::"
|
|
|
msgstr "使用 `pywebio.platform.django.webio_view()` 来获取在Django中运行PyWebIO应用的视图函数::"
|
|
|
|
|
|
-#: ../../guide.rst:804
|
|
|
+#: ../../guide.rst:806
|
|
|
msgid ""
|
|
|
"# urls.py\n"
|
|
|
"\n"
|
|
@@ -1300,7 +1301,7 @@ msgid ""
|
|
|
"]"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:817
|
|
|
+#: ../../guide.rst:819
|
|
|
msgid ""
|
|
|
"In above code, we add a routing rule to bind the view function of the PyWebIO application to the ``/tool`` path. After starting the Django server, "
|
|
|
"visit ``http://localhost/tool`` to open the PyWebIO application"
|
|
@@ -1308,15 +1309,15 @@ msgstr ""
|
|
|
"以上代码使用添加了一条路由规则将PyWebIO应用的视图函数绑定到 ``/tool`` 路径下。\n"
|
|
|
"启动Django应用后,访问 ``http://localhost/tool`` 即可打开PyWebIO应用"
|
|
|
|
|
|
-#: ../../guide.rst:820
|
|
|
+#: ../../guide.rst:822
|
|
|
msgid "aiohttp"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:824
|
|
|
+#: ../../guide.rst:826
|
|
|
msgid "**aiohttp**"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:826
|
|
|
+#: ../../guide.rst:828
|
|
|
msgid ""
|
|
|
"Use `pywebio.platform.aiohttp.webio_handler()` to get the `Request Handler <https://docs.aiohttp.org/en/stable/web_quickstart.html#aiohttp-web-"
|
|
|
"handler>`_ coroutine for running PyWebIO applications in aiohttp::"
|
|
@@ -1324,7 +1325,7 @@ msgstr ""
|
|
|
"使用 `pywebio.platform.aiohttp.webio_handler()` 来获取在aiohttp中运行PyWebIO应用的 `Request Handler <https://docs.aiohttp.org/en/stable/"
|
|
|
"web_quickstart.html#aiohttp-web-handler>`_ 协程::"
|
|
|
|
|
|
-#: ../../guide.rst:828
|
|
|
+#: ../../guide.rst:830
|
|
|
msgid ""
|
|
|
"from aiohttp import web\n"
|
|
|
"from pywebio.platform.aiohttp import webio_handler\n"
|
|
@@ -1336,11 +1337,11 @@ msgid ""
|
|
|
"web.run_app(app, host='localhost', port=80)"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:837
|
|
|
+#: ../../guide.rst:839
|
|
|
msgid "After starting the aiohttp server, visit ``http://localhost/tool`` to open the PyWebIO application"
|
|
|
msgstr "启动aiohttp应用后,访问 ``http://localhost/tool`` 即可打开PyWebIO应用"
|
|
|
|
|
|
-#: ../../guide.rst:841
|
|
|
+#: ../../guide.rst:843
|
|
|
msgid ""
|
|
|
"PyWebIO uses the WebSocket protocol to communicate with the browser in aiohttp. If your aiohttp server is behind a reverse proxy (such as Nginx), "
|
|
|
"you may need to configure the reverse proxy to support the WebSocket protocol. :ref:`Here <nginx_ws_config>` is an example of Nginx WebSocket "
|
|
@@ -1349,26 +1350,26 @@ msgstr ""
|
|
|
"当使用aiohttp后端时,PyWebIO使用WebSocket协议和浏览器进行通讯,如果你的aiohttp应用处在反向代理(比如Nginx)之后,\n"
|
|
|
"可能需要特别配置反向代理来支持WebSocket协议,:ref:`这里 <nginx_ws_config>` 有一个Nginx配置WebSocket的例子。"
|
|
|
|
|
|
-#: ../../guide.rst:844
|
|
|
+#: ../../guide.rst:846
|
|
|
msgid "FastAPI/Starlette"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:848
|
|
|
+#: ../../guide.rst:850
|
|
|
msgid "**FastAPI/Starlette**"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:850
|
|
|
+#: ../../guide.rst:852
|
|
|
msgid ""
|
|
|
"Use `pywebio.platform.fastapi.webio_routes()` to get the FastAPI/Starlette routes for running PyWebIO applications. You can mount the routes to "
|
|
|
"your FastAPI/Starlette app."
|
|
|
msgstr ""
|
|
|
"使用 `pywebio.platform.fastapi.webio_routes()` 来获取在FastAPI/Starlette中运行PyWebIO应用的路由组件,你可以将其挂载在到FastAPI/Starlette应用中。"
|
|
|
|
|
|
-#: ../../guide.rst:853
|
|
|
+#: ../../guide.rst:855
|
|
|
msgid "FastAPI::"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:855
|
|
|
+#: ../../guide.rst:857
|
|
|
msgid ""
|
|
|
"from fastapi import FastAPI\n"
|
|
|
"from pywebio.platform.fastapi import webio_routes\n"
|
|
@@ -1383,11 +1384,11 @@ msgid ""
|
|
|
"app.mount(\"/tool\", FastAPI(routes=webio_routes(task_func)))"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:867
|
|
|
+#: ../../guide.rst:869
|
|
|
msgid "Starlette::"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:869
|
|
|
+#: ../../guide.rst:871
|
|
|
msgid ""
|
|
|
"from starlette.applications import Starlette\n"
|
|
|
"from starlette.responses import JSONResponse\n"
|
|
@@ -1403,17 +1404,17 @@ msgid ""
|
|
|
"])"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:882
|
|
|
+#: ../../guide.rst:884
|
|
|
msgid "After starting the server by using ``uvicorn <module>:app`` , visit ``http://localhost:8000/tool/`` to open the PyWebIO application"
|
|
|
msgstr "使用 ``uvicorn <module>:app` 启动server后,访问 ``http://localhost:8000/tool/`` 即可打开PyWebIO应用"
|
|
|
|
|
|
-#: ../../guide.rst:884
|
|
|
+#: ../../guide.rst:886
|
|
|
msgid ""
|
|
|
"See also: `FastAPI doc <https://fastapi.tiangolo.com/advanced/sub-applications/>`_ , `Starlette doc <https://www.starlette.io/routing/#submounting-"
|
|
|
"routes>`_"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:888
|
|
|
+#: ../../guide.rst:890
|
|
|
msgid ""
|
|
|
"PyWebIO uses the WebSocket protocol to communicate with the browser in FastAPI/Starlette. If your server is behind a reverse proxy (such as Nginx), "
|
|
|
"you may need to configure the reverse proxy to support the WebSocket protocol. :ref:`Here <nginx_ws_config>` is an example of Nginx WebSocket "
|
|
@@ -1422,15 +1423,15 @@ msgstr ""
|
|
|
"当使用FastAPI或Starlette后端时,PyWebIO使用WebSocket协议和浏览器进行通讯,如果你的aiohttp应用处在反向代理(比如Nginx)之后,\n"
|
|
|
"可能需要特别配置反向代理来支持WebSocket协议,:ref:`这里 <nginx_ws_config>` 有一个Nginx配置WebSocket的例子。"
|
|
|
|
|
|
-#: ../../guide.rst:894
|
|
|
+#: ../../guide.rst:896
|
|
|
msgid "Notes"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:895
|
|
|
+#: ../../guide.rst:897
|
|
|
msgid "**Deployment in production**"
|
|
|
msgstr "**生产环境部署**"
|
|
|
|
|
|
-#: ../../guide.rst:897
|
|
|
+#: ../../guide.rst:899
|
|
|
msgid ""
|
|
|
"In your production system, you may want to deploy the web applications with some WSGI/ASGI servers such as uWSGI, Gunicorn, and Uvicorn. Since "
|
|
|
"PyWebIO applications store session state in memory of process, when you use HTTP-based sessions (Flask and Django) and spawn multiple workers to "
|
|
@@ -1441,7 +1442,7 @@ msgstr ""
|
|
|
"基于 HTTP 的会话(使用Flask 和 Django后端时)并生成多个进程来处理请求时,请求可能会被分发到错误的进程中。因此,在使用基于 HTTP 的会话时,只能启动一"
|
|
|
"个进程来处理请求。"
|
|
|
|
|
|
-#: ../../guide.rst:902
|
|
|
+#: ../../guide.rst:904
|
|
|
msgid ""
|
|
|
"If you still want to use multiple processes to increase concurrency, one way is to use Uvicorn+FastAPI, or you can also start multiple Tornado/"
|
|
|
"aiohttp processes and add external load balancer (such as HAProxy or nginx) before them. Those backends use the WebSocket protocol to communicate "
|
|
@@ -1450,11 +1451,11 @@ msgstr ""
|
|
|
"如果仍然希望使用多进程来提高并发,一种方式是使用 Uvicorn+FastAPI,或者你也可以启动多个Tornado/aiohttp进程,并在它们之前添加外部的负载均衡软件(如 "
|
|
|
"HAProxy 或 nginx)。这些后端使用 WebSocket 协议与浏览器进行通信,所以不存在上述问题。"
|
|
|
|
|
|
-#: ../../guide.rst:905
|
|
|
+#: ../../guide.rst:907
|
|
|
msgid "**Static resources Hosting**"
|
|
|
msgstr "**PyWebIO静态资源的托管**"
|
|
|
|
|
|
-#: ../../guide.rst:907
|
|
|
+#: ../../guide.rst:909
|
|
|
msgid ""
|
|
|
"By default, the front-end of PyWebIO gets required static resources from CDN. If you want to deploy PyWebIO applications in an offline environment, "
|
|
|
"you need to host static files by yourself, and set the ``cdn`` parameter of ``webio_view()`` or ``webio_handler()`` to ``False``."
|
|
@@ -1462,7 +1463,7 @@ msgstr ""
|
|
|
"PyWebIO默认使用CDN来获取前端的静态资源,如果要将PyWebIO应用部署到离线环境中,需要自行托管静态文件,\n"
|
|
|
"并将 ``webio_view()`` 或 ``webio_handler()`` 的 ``cdn`` 参数设置为 ``False`` 。"
|
|
|
|
|
|
-#: ../../guide.rst:909
|
|
|
+#: ../../guide.rst:911
|
|
|
msgid ""
|
|
|
"When setting ``cdn=False`` , you need to host the static resources in the same directory as the PyWebIO application. In addition, you can also pass "
|
|
|
"a string to ``cdn`` parameter to directly set the URL of PyWebIO static resources directory."
|
|
@@ -1470,30 +1471,30 @@ msgstr ""
|
|
|
"``cdn=False`` 时需要将静态资源托管在和PyWebIO应用同级的目录下。\n"
|
|
|
"同时,也可以通过 ``cdn`` 参数直接设置PyWebIO静态资源的URL目录。"
|
|
|
|
|
|
-#: ../../guide.rst:912
|
|
|
+#: ../../guide.rst:914
|
|
|
msgid ""
|
|
|
"The path of the static file of PyWebIO is stored in ``pywebio.STATIC_PATH``, you can use the command ``python3 -c \"import pywebio; print(pywebio."
|
|
|
"STATIC_PATH)\"`` to print it out."
|
|
|
msgstr ""
|
|
|
"PyWebIO的静态文件的路径保存在 ``pywebio.STATIC_PATH`` 中,可使用命令 ``python3 -c \"import pywebio; print(pywebio.STATIC_PATH)\"`` 将其打印出来。"
|
|
|
|
|
|
-#: ../../guide.rst:914
|
|
|
+#: ../../guide.rst:916
|
|
|
msgid ""
|
|
|
"``start_server()`` and ``path_deploy()`` also support ``cdn`` parameter, if it is set to ``False``, the static resource will be hosted in local "
|
|
|
"server automatically, without manual hosting."
|
|
|
msgstr "使用 ``start_server()`` 启动的应用,如果将 ``cdn`` 参数设置为 ``False`` ,会自动启动一个本地的静态资源托管服务,无需手动托管。"
|
|
|
|
|
|
-#: ../../guide.rst:920
|
|
|
+#: ../../guide.rst:922
|
|
|
msgid "Coroutine-based session"
|
|
|
msgstr "基于协程的会话"
|
|
|
|
|
|
-#: ../../guide.rst:922
|
|
|
+#: ../../guide.rst:924
|
|
|
msgid ""
|
|
|
"This section will introduce the advanced features of PyWebIO --- coroutine-based session. In most cases, you don’t need it. All functions or "
|
|
|
"methods in PyWebIO that are only used for coroutine sessions are specifically noted in the document."
|
|
|
msgstr "关于协程内容属于高级特性,您不必使用此部分也可以实现PyWebIO支持的全部功能。PyWebIO中所有仅用于协程会话的函数或方法都在文档中有特别说明。"
|
|
|
|
|
|
-#: ../../guide.rst:924
|
|
|
+#: ../../guide.rst:926
|
|
|
msgid ""
|
|
|
"PyWebIO's session is based on thread by default. Each time a user opens a session connection to the server, PyWebIO will start a thread to run the "
|
|
|
"task function. In addition to thread-based sessions, PyWebIO also provides coroutine-based sessions. Coroutine-based sessions accept coroutine "
|
|
@@ -1502,7 +1503,7 @@ msgstr ""
|
|
|
"PyWebIO的会话实现默认是基于线程的,用户每打开一个和服务端的会话连接,PyWebIO会启动一个线程来运行任务函数。\n"
|
|
|
"除了基于线程的会话,PyWebIO还提供了基于协程的会话。基于协程的会话接受协程函数作为任务函数。"
|
|
|
|
|
|
-#: ../../guide.rst:926
|
|
|
+#: ../../guide.rst:928
|
|
|
msgid ""
|
|
|
"The session based on the coroutine is a single-thread model, which means that all sessions run in a single thread. For IO-bound tasks, coroutines "
|
|
|
"take up fewer resources than threads and have performance comparable to threads. In addition, the context switching of the coroutine is "
|
|
@@ -1511,17 +1512,17 @@ msgstr ""
|
|
|
"基于协程的会话为单线程模型,所有会话都运行在一个线程内。对于IO密集型的任务,协程比线程占用更少的资源同时又拥有媲美于线程的性能。\n"
|
|
|
"另外,协程的上下文切换具有可预测性,能够减少程序同步与加锁的需要,可以有效避免大多数临界区问题。"
|
|
|
|
|
|
-#: ../../guide.rst:929
|
|
|
+#: ../../guide.rst:931
|
|
|
msgid "Using coroutine session"
|
|
|
msgstr "使用协程会话"
|
|
|
|
|
|
-#: ../../guide.rst:931
|
|
|
+#: ../../guide.rst:933
|
|
|
msgid ""
|
|
|
"To use coroutine-based session, you need to use the ``async`` keyword to declare the task function as a coroutine function, and use the ``await`` "
|
|
|
"syntax to call the PyWebIO input function:"
|
|
|
msgstr "要使用基于协程的会话,需要使用 ``async`` 关键字将任务函数声明为协程函数,并使用 ``await`` 语法调用PyWebIO输入函数:"
|
|
|
|
|
|
-#: ../../guide.rst:933
|
|
|
+#: ../../guide.rst:935
|
|
|
#, python-format
|
|
|
msgid ""
|
|
|
" from pywebio.input import *\n"
|
|
@@ -1535,7 +1536,7 @@ msgid ""
|
|
|
" start_server(say_hello, auto_open_webbrowser=True)"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:947
|
|
|
+#: ../../guide.rst:949
|
|
|
msgid ""
|
|
|
"In the coroutine task function, you can also use ``await`` to call other coroutines or ( `awaitable objects <https://docs.python.org/3/library/"
|
|
|
"asyncio-task.html#asyncio-awaitables>`_ ) in the standard library `asyncio <https://docs.python.org/3/library/asyncio.html>`_:"
|
|
@@ -1543,7 +1544,7 @@ msgstr ""
|
|
|
"在协程任务函数中,也可以使用 ``await`` 调用其他协程或标准库 `asyncio <https://docs.python.org/3/library/asyncio.html>`_ 中的可等待对象( `awaitable "
|
|
|
"objects <https://docs.python.org/3/library/asyncio-task.html#asyncio-awaitables>`_ ):"
|
|
|
|
|
|
-#: ../../guide.rst:949
|
|
|
+#: ../../guide.rst:951
|
|
|
msgid ""
|
|
|
" import asyncio\n"
|
|
|
" from pywebio import start_server\n"
|
|
@@ -1560,7 +1561,7 @@ msgid ""
|
|
|
" start_server(main, auto_open_webbrowser=True)"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:968
|
|
|
+#: ../../guide.rst:970
|
|
|
msgid ""
|
|
|
"In coroutine-based session, all input functions defined in the :doc:`pywebio.input </input>` module need to use ``await`` syntax to get the return "
|
|
|
"value. Forgetting to use ``await`` will be a common error when using coroutine-based session."
|
|
@@ -1568,47 +1569,47 @@ msgstr ""
|
|
|
"在基于协程的会话中, :doc:`pywebio.input </input>` 模块中的定义输入函数都需要使用 ``await`` 语法来获取返回值,忘记使用 ``await`` 将会是在使用基于协"
|
|
|
"程的会话时常出现的错误。"
|
|
|
|
|
|
-#: ../../guide.rst:970
|
|
|
+#: ../../guide.rst:972
|
|
|
msgid "Other functions that need to use ``await`` syntax in the coroutine session are:"
|
|
|
msgstr "其他在协程会话中也需要使用 ``await`` 语法来进行调用函数有:"
|
|
|
|
|
|
-#: ../../guide.rst:972
|
|
|
+#: ../../guide.rst:974
|
|
|
msgid "`pywebio.session.run_asyncio_coroutine(coro_obj) <pywebio.session.run_asyncio_coroutine>`"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:973
|
|
|
+#: ../../guide.rst:975
|
|
|
msgid "`pywebio.session.eval_js(expression) <pywebio.session.eval_js>`"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:974
|
|
|
+#: ../../guide.rst:976
|
|
|
msgid "`pywebio.session.hold() <pywebio.session.hold>`"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:978
|
|
|
+#: ../../guide.rst:980
|
|
|
msgid ""
|
|
|
"Although the PyWebIO coroutine session is compatible with the ``awaitable objects`` in the standard library ``asyncio``, the ``asyncio`` library is "
|
|
|
"not compatible with the ``awaitable objects`` in the PyWebIO coroutine session."
|
|
|
msgstr "虽然PyWebIO的协程会话兼容标准库 ``asyncio`` 中的 ``awaitable objects`` ,但 ``asyncio`` 库不兼容PyWebIO协程会话中的 ``awaitable objects`` ."
|
|
|
|
|
|
-#: ../../guide.rst:980
|
|
|
+#: ../../guide.rst:982
|
|
|
msgid ""
|
|
|
"That is to say, you can't pass PyWebIO ``awaitable objects`` to the ``asyncio`` functions that accept ``awaitable objects``. For example, the "
|
|
|
"following calls are **not supported** ::"
|
|
|
msgstr ""
|
|
|
"也就是说,无法将PyWebIO中的 ``awaitable objects`` 传入 ``asyncio`` 中的接受 ``awaitable objects`` 作为参数的函数中,比如如下调用是 **不被支持的** ::"
|
|
|
|
|
|
-#: ../../guide.rst:982
|
|
|
+#: ../../guide.rst:984
|
|
|
msgid ""
|
|
|
"await asyncio.shield(pywebio.input())\n"
|
|
|
"await asyncio.gather(asyncio.sleep(1), pywebio.session.eval_js('1+1'))\n"
|
|
|
"task = asyncio.create_task(pywebio.input())"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:989
|
|
|
+#: ../../guide.rst:991
|
|
|
msgid "Concurrency in coroutine-based sessions"
|
|
|
msgstr "协程会话的并发"
|
|
|
|
|
|
-#: ../../guide.rst:991
|
|
|
+#: ../../guide.rst:993
|
|
|
msgid ""
|
|
|
"In coroutine-based session, you can start new thread, but you cannot call PyWebIO interactive functions in it (`register_thread() <pywebio.session."
|
|
|
"register_thread>` is not available in coroutine session). But you can use `run_async(coro) <pywebio.session.run_async>` to execute a coroutine "
|
|
@@ -1618,7 +1619,7 @@ msgstr ""
|
|
|
"用)。\n"
|
|
|
"但你可以使用 `run_async(coro) <pywebio.session.run_async>` 来异步执行一个协程对象,新协程内可以使用PyWebIO交互函数:"
|
|
|
|
|
|
-#: ../../guide.rst:993
|
|
|
+#: ../../guide.rst:995
|
|
|
msgid ""
|
|
|
" from pywebio import start_server\n"
|
|
|
" from pywebio.session import run_async\n"
|
|
@@ -1636,7 +1637,7 @@ msgid ""
|
|
|
" start_server(main, auto_open_webbrowser=True)"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:1012
|
|
|
+#: ../../guide.rst:1014
|
|
|
msgid ""
|
|
|
"`run_async(coro) <pywebio.session.run_async>` returns a `TaskHandler <pywebio.session.coroutinebased.TaskHandler>`, which can be used to query the "
|
|
|
"running status of the coroutine or close the coroutine."
|
|
@@ -1644,13 +1645,13 @@ msgstr ""
|
|
|
"`run_async(coro) <pywebio.session.run_async>` 返回一个 `TaskHandler <pywebio.session.coroutinebased.TaskHandler>` ,通过该 `TaskHandler <pywebio."
|
|
|
"session.coroutinebased.TaskHandler>` 可以查询协程运行状态和关闭协程。"
|
|
|
|
|
|
-#: ../../guide.rst:1017
|
|
|
+#: ../../guide.rst:1019
|
|
|
msgid ""
|
|
|
"Similar to thread-based session, in coroutine-based session, when the task function and the coroutine running through `run_async() <pywebio.session."
|
|
|
"run_async>` in the session are all finished, the session is closed."
|
|
|
msgstr "与基于线程的会话类似,在基于协程的会话中,当任务函数和在会话内通过 `run_async() <pywebio.session.run_async>` 运行的协程全部结束后,会话关闭。"
|
|
|
|
|
|
-#: ../../guide.rst:1019
|
|
|
+#: ../../guide.rst:1021
|
|
|
msgid ""
|
|
|
"If the close of the session is caused by the user closing the browser, the behavior of PyWebIO is the same as :ref:`Thread-based session "
|
|
|
"<session_close>`: After the browser page closed, PyWebIO input function calls that have not yet returned in the current session will cause "
|
|
@@ -1662,23 +1663,23 @@ msgstr ""
|
|
|
"的调用将会产生 `SessionNotFoundException <pywebio.exceptions.SessionNotFoundException>` 或 `SessionClosedException <pywebio.exceptions."
|
|
|
"SessionClosedException>` 异常。"
|
|
|
|
|
|
-#: ../../guide.rst:1021
|
|
|
+#: ../../guide.rst:1023
|
|
|
msgid "`defer_call(func) <pywebio.session.defer_call>` also available in coroutine session."
|
|
|
msgstr "协程会话也同样支持使用 `defer_call(func) <pywebio.session.defer_call>` 来设置会话结束时需要调用的函数。"
|
|
|
|
|
|
-#: ../../guide.rst:1026
|
|
|
+#: ../../guide.rst:1028
|
|
|
msgid "Integration with Web Framework"
|
|
|
msgstr "协程会话与Web框架集成"
|
|
|
|
|
|
-#: ../../guide.rst:1028
|
|
|
+#: ../../guide.rst:1030
|
|
|
msgid "The PyWebIO application that using coroutine-based session can also be integrated to the web framework."
|
|
|
msgstr "基于协程的会话同样可以与Web框架进行集成,只需要在原来传入任务函数的地方改为传入协程函数即可。"
|
|
|
|
|
|
-#: ../../guide.rst:1030
|
|
|
+#: ../../guide.rst:1032
|
|
|
msgid "However, there are some limitations when using coroutine-based sessions to integrate into Flask or Django:"
|
|
|
msgstr "但当前在使用基于协程的会话集成进Flask或Django时,存在一些限制:"
|
|
|
|
|
|
-#: ../../guide.rst:1032
|
|
|
+#: ../../guide.rst:1034
|
|
|
msgid ""
|
|
|
"First, when ``await`` the coroutine objects/awaitable objects in the ``asyncio`` module, you need to use `run_asyncio_coroutine() <pywebio.session."
|
|
|
"run_asyncio_coroutine>` to wrap the coroutine object."
|
|
@@ -1686,15 +1687,15 @@ msgstr ""
|
|
|
"一是协程函数内还无法直接通过 ``await`` 直接等待asyncio库中的协程对象,目前需要使用 `run_asyncio_coroutine() <pywebio.session."
|
|
|
"run_asyncio_coroutine>` 进行包装。"
|
|
|
|
|
|
-#: ../../guide.rst:1034
|
|
|
+#: ../../guide.rst:1036
|
|
|
msgid "Secondly, you need to start a new thread to run the event loop before starting a Flask/Django server."
|
|
|
msgstr "二是,在启动Flask/Django这类基于线程的服务器之前需要启动一个单独的线程来运行事件循环。"
|
|
|
|
|
|
-#: ../../guide.rst:1036
|
|
|
+#: ../../guide.rst:1038
|
|
|
msgid "Example of coroutine-based session integration into Flask:"
|
|
|
msgstr "使用基于协程的会话集成进Flask的示例:"
|
|
|
|
|
|
-#: ../../guide.rst:1038
|
|
|
+#: ../../guide.rst:1040
|
|
|
msgid ""
|
|
|
" import asyncio\n"
|
|
|
" import threading\n"
|
|
@@ -1719,21 +1720,21 @@ msgid ""
|
|
|
" app.run(host='localhost', port=80)"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:1063
|
|
|
+#: ../../guide.rst:1065
|
|
|
msgid ""
|
|
|
"Finally, coroutine-based session is not available in the script mode. You always need to use ``start_server()`` to run coroutine task function or "
|
|
|
"integrate it to a web framework."
|
|
|
msgstr "最后,使用PyWebIO编写的协程函数不支持Script模式,总是需要使用 ``start_server`` 来启动一个服务或者集成进Web框架来调用。"
|
|
|
|
|
|
-#: ../../guide.rst:1066
|
|
|
+#: ../../guide.rst:1068
|
|
|
msgid "Last but not least"
|
|
|
msgstr ""
|
|
|
|
|
|
-#: ../../guide.rst:1068
|
|
|
+#: ../../guide.rst:1070
|
|
|
msgid "This is all features of PyWebIO, you can continue to read the rest of the documents, or start writing your PyWebIO applications now."
|
|
|
msgstr "以上就是PyWebIO的全部功能了,你可以继续阅读接下来的文档,或者立即开始PyWebIO应用的编写了。"
|
|
|
|
|
|
-#: ../../guide.rst:1070
|
|
|
+#: ../../guide.rst:1072
|
|
|
msgid ""
|
|
|
"Finally, please allow me to provide one more suggestion. When you encounter a design problem when using PyWebIO, you can ask yourself a question: "
|
|
|
"What would I do if it is in a terminal program? If you already have the answer, it can be done in the same way with PyWebIO. If the problem "
|
|
@@ -1743,7 +1744,7 @@ msgstr ""
|
|
|
"如果你已经有答案了,那么在PyWebIO中一样可以使用这样的方式完成。如果问题依然存在或者觉得解决方案不够好,\n"
|
|
|
"你可以考虑使用 :doc:`pin <./pin>` 模块。"
|
|
|
|
|
|
-#: ../../guide.rst:1073
|
|
|
+#: ../../guide.rst:1075
|
|
|
msgid "OK, Have fun with PyWebIO!"
|
|
|
msgstr ""
|
|
|
|
|
@@ -1814,3 +1815,13 @@ msgstr ""
|
|
|
#~ "以上代码使用 `webio_view(task_func) <pywebio.platform.flask.webio_view>` 来获得运行PyWebIO应用的Flask视图 ,并调用 `Flask.add_url_rule <https://"
|
|
|
#~ "flask.palletsprojects.com/en/1.1.x/api/#flask.Flask.add_url_rule>`_ 将其绑定在 ``/tool`` 路径下。启动Flask应用后,访问 ``http://localhost/tool`` "
|
|
|
#~ "即可打开PyWebIO应用。"
|
|
|
+
|
|
|
+#~ msgid ""
|
|
|
+#~ "The `start_server() <pywebio.platform.tornado.start_server>` provide a remote access support, when enabled (by passing `remote_access=True` to "
|
|
|
+#~ "`start_server()`), you can get a temporary public network access address for the current application, others can access your application via "
|
|
|
+#~ "this address. Using remote access makes it easy to temporarily share the application with others. This service is powered by `localhost.run "
|
|
|
+#~ "<https://localhost.run>`_."
|
|
|
+#~ msgstr ""
|
|
|
+#~ "`start_server() <pywebio.platform.tornado.start_server>` 提供了远程访问的支持,当开启远程访问后(通过在 `start_server()` 中传入 "
|
|
|
+#~ "`remote_access=True` 开启 ),你将会得到一个用于访问当前应用的临时的公网访问地址,其他人任何都可以使用此地址访问你的应用。远程接入可以很方便地将"
|
|
|
+#~ "应用临时分享给其他人。当前远程接入功能由 `localhost.run <https://localhost.run>`_ 提供。"
|