{"id":444902,"date":"2025-01-13T21:00:11","date_gmt":"2025-01-13T21:00:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=444902"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=444902","title":{"rendered":"<span>Brython: Python \u0432 \u0432\u0430\u0448\u0435\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 (\u0447.3)<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><a href=\"\/ru\/articles\/872822\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 1<\/a> \u2022 <a href=\"\/ru\/articles\/873174\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 2<\/a> \u2022 <span>\u0427\u0430\u0441\u0442\u044c 3<\/span> \u2022 <a href=\"\/ru\/article\/872792\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 4<\/a><\/p>\n<h2>\u0412\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 JavaScript<\/h2>\n<p><a class=\"anchor\" name=\"interacting-with-javascript\" id=\"interacting-with-javascript\"><\/a><\/p>\n<p>Brython \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 Python-\u043a\u043e\u0434\u0443 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043a\u043e\u0434\u043e\u043c JavaScript. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u2014 \u0434\u043e\u0441\u0442\u0443\u043f \u043a JavaScript \u0438\u0437 Brython. \u041e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0445\u043e\u0442\u044f \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d, \u043d\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d. \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 Python \u0432 JavaScript \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <a href=\"\/ru\/articles\/872792\/#javascript-unit-tests\" rel=\"noopener noreferrer nofollow\">\u042e\u043d\u0438\u0442 \u0422\u0435\u0441\u0442\u044b JavaScript<\/a>.<\/p>\n<h3>JavaScript<\/h3>\n<p><a class=\"anchor\" name=\"javascript\" id=\"javascript\"><\/a><\/p>\n<p>\u0414\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0432\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u043c\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u0434 Python \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0441 \u043a\u043e\u0434\u043e\u043c JavaScript. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043e\u043a\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0432\u044b\u0437\u0432\u0430\u0432 <em>browser.alert()<\/em>.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c <em>alert<\/em> \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0442\u0440\u0435\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445, \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 Brython, \u0430 \u043d\u0435 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 CPython:<\/p>\n<pre><code class=\"python\">&gt;&gt;&gt; import browser &gt;&gt;&gt; browser.alert(\"Real Python\")<\/code><\/pre>\n<p>\u0418\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>window<\/em>:<\/p>\n<pre><code class=\"python\">&gt;&gt;&gt; from browser import window &gt;&gt;&gt; window.alert(\"Real Python\")<\/code><\/pre>\n<p>\u0418\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>this<\/em>:<\/p>\n<pre><code class=\"python\">&gt;&gt;&gt; from javascript import this &gt;&gt;&gt; this().alert(\"Real Python\")<\/code><\/pre>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043d\u043e\u0432\u043e\u043c\u0443 \u0441\u043b\u043e\u044e, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u043c\u0443 Brython, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0443 <em>alert()<\/em> \u0438 <em>window<\/em>, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <em>alert<\/em> \u043a\u0430\u043a <em>browser.window<\/em> \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043a\u0430\u043a <em>javascript.this<\/em>.<\/p>\n<p>\u0412\u043e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 Brython, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c JavaScript:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>\u041c\u043e\u0434\u0443\u043b\u0438<\/p>\n<\/th>\n<th>\n<p>\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442<\/p>\n<\/th>\n<th>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">browser<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u0438 \u043c\u043e\u0434\u0443\u043b\u0438<\/p>\n<\/td>\n<td>\n<p align=\"left\"><em>browser.alert()<\/em><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">browser.document<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u043e\u0441\u0442\u0443\u043f \u043a DOM<\/p>\n<\/td>\n<td>\n<p align=\"left\"><em>document.getElementById(&#171;element-id&#187;)<\/em><\/p>\n<p align=\"left\"><em>document[&#171;element-id&#187;]<\/em><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">browser.html<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u043e\u0437\u0434\u0430\u0435\u0442 HTML-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b<\/p>\n<\/td>\n<td>\n<p align=\"left\"><em>html.H1(&#171;This is the title&#187;)<\/em><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">browser.window<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Window\" rel=\"noopener noreferrer nofollow\"><em>Window<\/em><\/a> \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c<\/p>\n<\/td>\n<td>\n<p align=\"left\"><em>window.navigator <\/em><\/p>\n<p align=\"left\"><em>window.frames<\/em><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><em>javascript.JSON.parse()<\/em><\/p>\n<\/td>\n<td>\n<p align=\"left\">\n<\/td>\n<td>\n<p align=\"left\"><em>javascript.this()<\/em><\/p>\n<p align=\"left\"><em>javascript.JSON.parse()<\/em>  <\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c JavaScript \u0438 API, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0432\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c JavaScript, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 JavaScript \u0438\u0437 Brython:<\/p>\n<pre><code class=\"xml\">&lt;!doctype html&gt; &lt;html&gt;   &lt;head&gt;     &lt;meta charset=\"utf-8\"&gt;     &lt;script         src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/brython\/3.13.0\/brython.js\"&gt;     &lt;\/script&gt;     &lt;script type=\"text\/javascript\"&gt;       function myMessageBox(name) {         window.alert(`Hello ${name}!`);       }     &lt;\/script&gt;   &lt;\/head&gt;   &lt;body onload=\"brython()\"&gt;     &lt;script type=\"text\/python\"&gt;       from browser import window       window.myMessageBox(\"Jon\")     &lt;\/script&gt;   &lt;\/body&gt; &lt;\/html&gt;<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 9<\/strong> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>myMessageBox()<\/em> \u0432 \u0431\u043b\u043e\u043a\u0435 JavaScript.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 17<\/strong> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <em>myMessageBox()<\/em>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0443 \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c JavaScript. \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <a href=\"\/ru\/articles\/873176\/#web-ui-framework\" rel=\"noopener noreferrer nofollow\">\u0424\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Web UI<\/a>, \u0433\u0434\u0435 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 Vue.js, \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c UI-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c.<\/p>\n<h3>\u0412\u0435\u0431-API \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430<\/h3>\n<p><a class=\"anchor\" name=\"browser-web-api\" id=\"browser-web-api\"><\/a><\/p>\n<p>\u0411\u0440\u0430\u0443\u0437\u0435\u0440\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0432\u0435\u0431-API, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u0438\u0437 JavaScript, \u0438 Brython \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0442\u0435\u043c \u0436\u0435 API. \u0412 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0432\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u0435 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440 Base64 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430\u043c\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<p>\u0412\u0435\u0431-API, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u2014 \u044d\u0442\u043e <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Web_Storage_API\" rel=\"noopener noreferrer nofollow\">Web Storage API<\/a>. \u041e\u043d \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0434\u0432\u0430 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Window\/sessionStorage\" rel=\"noopener noreferrer nofollow\"><em>sessionStorage<\/em><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Window\/localStorage\" rel=\"noopener noreferrer nofollow\"><em>localStorage<\/em><\/a><\/p>\n<\/li>\n<\/ol>\n<p>\u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>localStorage<\/em> \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435.<\/p>\n<p>\u041a\u0430\u043a \u0432\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u0440\u0430\u043d\u0435\u0435, \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440 Base64 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0432\u0445\u043e\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0441 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0432 Base64 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u0414\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u043d\u043e \u043e\u0447\u0438\u0449\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0435\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435. \u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 <em>localStorage<\/em> \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430\u043c\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. <em>localStorage<\/em> \u2014 \u044d\u0442\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/Key-value_database\" rel=\"noopener noreferrer nofollow\">\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043a\u043b\u044e\u0447\u0435\u0439 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/a>.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f <em>localStorage<\/em>, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c <em>storage<\/em>. \u0427\u0442\u043e\u0431\u044b \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u043b\u0438\u0436\u0435 \u043a \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0432\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f <em>localStorage<\/em> \u0432 <a href=\"https:\/\/realpython.com\/python-json\/\" rel=\"noopener noreferrer nofollow\">\u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON<\/a>. \u041a\u043b\u044e\u0447\u043e\u043c \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 <em>b64data<\/em>. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u044b \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>load_data()<\/em>:<\/p>\n<pre><code class=\"python\">from browser.local_storage import storage import json, base64  def load_data():     data = storage.get(\"b64data\")     if data:         return json.loads(data)     else:         storage[\"b64data\"] = json.dumps({})         return {}<\/code><\/pre>\n<p><em>load_data()<\/em> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043a\u043e\u0434\u0430 Python. \u041e\u043d\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 JSON \u0438\u0437 <em>localStorage<\/em> \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c Python, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0436\u0438\u0437\u043d\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u0415\u0441\u043b\u0438 \u043e\u043d\u0430 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 <em>b64data<\/em> \u0432 <em>localStorage<\/em>, \u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0434\u043b\u044f \u043a\u043b\u044e\u0447\u0430 <em>b64data<\/em> \u0432 <em>localStorage<\/em> \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 Python, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>load_data()<\/em>. \u041e\u043d \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0431-API <em>localStorage<\/em> \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u043c\u0435\u0441\u0442\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u0430\u043a \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430.<\/p>\n<pre><code class=\"python\">from browser import document, prompt, html, alert from browser.local_storage import storage import json, base64  def load_data():     data = storage.get(\"b64data\")     if data:         return json.loads(data)     else:         storage[\"b64data\"] = json.dumps({})         return {}  def base64_compute(evt):     value = document[\"text-src\"].value     if not value:         alert(\"You need to enter a value\")         return     if value in b64_map:         alert(f\"'{value}' already exists: '{b64_map[value]}'\")         return     b64data = base64.b64encode(value.encode()).decode()     b64_map[value] = b64data     storage[\"b64data\"] = json.dumps(b64_map)     display_map()  def clear_map(evt):     b64_map.clear()     storage[\"b64data\"] = json.dumps({})     document[\"b64-display\"].clear()  def display_map():     if not b64_map:         return     table = html.TABLE(Class=\"pure-table\")     table &lt;= html.THEAD(html.TR(html.TH(\"Text\") + html.TH(\"Base64\")))     table &lt;= (html.TR(html.TD(key) + html.TD(b64_map[key])) for key in b64_map)     base64_display = document[\"b64-display\"]     base64_display.clear()     base64_display &lt;= table     document[\"text-src\"].value = \"\"  b64_map = load_data() display_map() document[\"submit\"].bind(\"click\", base64_compute) document[\"clear-btn\"].bind(\"click\", clear_map)<\/code><\/pre>\n<p>\u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c <em>b64_map<\/em> \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <em>load_data()<\/em> \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0444\u0430\u0439\u043b\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0437\u043e\u0432\u0430 <em>brython()<\/em>. \u041a\u043e\u0433\u0434\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f, \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u0438\u0437 <em>localStorage<\/em>.<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 Base64, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <em>b64_map<\/em> \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/JSON\" rel=\"noopener noreferrer nofollow\">JSON<\/a> \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435. \u041a\u043b\u044e\u0447 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u2014 <em>b64data<\/em>.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u043e \u0432\u0441\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u0432\u0435\u0431-API \u0438\u0437 <em>browser<\/em> \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0443\u0431\u043c\u043e\u0434\u0443\u043b\u0435\u0439. \u0412\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0443 \u043a \u0432\u0435\u0431-API \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432 <a href=\"https:\/\/brython.info\/static_doc\/en\/jsobjects.html\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Brython<\/a>. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0441\u043c. <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0432\u0435\u0431-API<\/a>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <a href=\"https:\/\/brython.info\/console.html\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043d\u0441\u043e\u043b\u044c Brython<\/a> \u0434\u043b\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 \u0432\u0435\u0431-API.<\/p>\n<p>\u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u0432\u0430\u043c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 Python \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0438\u0437 \u0432\u0435\u0431-API. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 Python-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f Base64-\u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 <em>base64.b64encode()<\/em>, \u0445\u043b\u044c\u044f \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JavaScript-\u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/WindowOrWorkerGlobalScope\/btoa\" rel=\"noopener noreferrer nofollow\"><em>btoa()<\/em><\/a>:<\/p>\n<pre><code class=\"python\">&gt;&gt;&gt; from browser import window &gt;&gt;&gt; window.btoa(\"Real Python\") 'UmVhbCBQeXRob24='<\/code><\/pre>\n<p>\u041c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0432 \u043e\u043d\u043b\u0430\u0439\u043d-\u043a\u043e\u043d\u0441\u043e\u043b\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <em>window.btoa()<\/em> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 Brython, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a <em>base64.b64encode()<\/em> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0441 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 Python, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/realpython.com\/cpython-source-code-guide\/\" rel=\"noopener noreferrer nofollow\">CPython<\/a>. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 CPython <em>base64.b64encode()<\/em> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0438\u043f\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 <em>bytearray<\/em>, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a JavaScript-\u0444\u0443\u043d\u043a\u0446\u0438\u044f <em>window.btoa()<\/em> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u0436\u043d\u0435\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 JavaScript-\u0432\u0435\u0440\u0441\u0438\u044e.<\/p>\n<h3>\u0424\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Web UI<\/h3>\n<p><a class=\"anchor\" name=\"web-ui-framework\" id=\"web-ui-framework\"><\/a><\/p>\n<p>\u041f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 UI-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 JavaScript, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <a href=\"https:\/\/angular.io\/\" rel=\"noopener noreferrer nofollow\">Angular<\/a>, <a href=\"https:\/\/reactjs.org\/\" rel=\"noopener noreferrer nofollow\">React<\/a>, <a href=\"https:\/\/vuejs.org\/\" rel=\"noopener noreferrer nofollow\">Vue.js<\/a> \u0438\u043b\u0438 <a href=\"https:\/\/svelte.dev\/\" rel=\"noopener noreferrer nofollow\">Svelte<\/a>, \u0441\u0442\u0430\u043b\u0438 \u0432\u0430\u0436\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 front-end-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430, \u0438 Brython \u043b\u0435\u0433\u043a\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432. \u0412 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Vue.js \u0432\u0435\u0440\u0441\u0438\u0438 3 \u0438 Brython.<\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u0442\u0435, \u2014 \u044d\u0442\u043e \u0444\u043e\u0440\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Hash_function\" rel=\"noopener noreferrer nofollow\">\u0445\u044d\u0448<\/a> \u0441\u0442\u0440\u043e\u043a\u0438. \u0412\u043e\u0442 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0439 HTML-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/536\/6de\/e77\/5366dee7719059c02f9d40d9b1214011.png\" alt=\"Brython Vue.js\" width=\"694\" height=\"493\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/536\/6de\/e77\/5366dee7719059c02f9d40d9b1214011.png\"\/><\/p>\n<div><figcaption>Brython Vue.js<\/figcaption><\/div>\n<\/figure>\n<p><em>body<\/em> HTML-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b:<\/p>\n<pre><code class=\"xml\">&lt;!DOCTYPE html &gt; &lt;html&gt;   &lt;head&gt;     &lt;meta charset=\"utf-8\"\/&gt;     &lt;link       rel=\"stylesheet\"       href=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/pure\/3.0.0\/pure-min.min.css\"\/&gt;     &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/vue\/3.5.13\/vue.global.prod.js\"&gt;&lt;\/script&gt;     &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/brython\/3.13.0\/brython.min.js\"&gt;&lt;\/script&gt;     &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/brython\/3.13.0\/brython_stdlib.min.js\"&gt;&lt;\/script&gt;     &lt;script src=\"main.py\" type=\"text\/python\"&gt;&lt;\/script&gt;     &lt;style&gt;       body { padding: 30px; }       [v-cloak] { visibility: hidden; }     &lt;\/style&gt;   &lt;\/head&gt;  &lt;body onload=\"brython(1)\"&gt;   &lt;div id=\"app\"&gt;     &lt;form class=\"pure-form\" onsubmit=\"return false;\"&gt;       &lt;fieldset&gt;         &lt;legend&gt;Hash Calculator&lt;\/legend&gt;         &lt;input type=\"text\" v-model.trim=\"input_text\"                placeholder=\"Text to Encode\" autocomplete=\"off\"\/&gt;         &lt;select v-model=\"algo\" v-cloak&gt;           &lt;option v-for=\"name in algos\" v-bind:value=\"name\"&gt;            &lt;\/option&gt;         &lt;\/select&gt;         &lt;button @click=\"compute_hash\" type=\"submit\"                 class=\"pure-button pure-button-primary\"&gt;Ok&lt;\/button&gt;       &lt;\/fieldset&gt;     &lt;\/form&gt;     &lt;p v-cloak&gt;&lt;\/p&gt;   &lt;\/div&gt; &lt;\/body&gt;<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 Vue, \u0442\u043e \u043d\u0438\u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u043a\u0440\u0430\u0442\u043a\u043e \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435\u0441\u044c \u043a <a href=\"https:\/\/vuejs.org\/v2\/guide\/\" rel=\"noopener noreferrer nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/v3.vuejs.org\/api\/directives.html\" rel=\"noopener noreferrer nofollow\">\u0414\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b Vue.js<\/a> \u2014 \u044d\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <em>v-<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 <a href=\"https:\/\/v3.vuejs.org\/guide\/component-basics.html\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 DOM \u0438 Vue.js<\/a>: <\/p>\n<ul>\n<li>\n<p><strong>v-model.trim=&#187;input_text&#187;<\/strong> \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a <a href=\"https:\/\/v3.vuejs.org\/guide\/migration\/v-model.html#_3-x-syntax\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0434\u0435\u043b\u0438 Vue<\/a> <em>input_text<\/em> \u0438 \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>v-model=&#187;algo&#187;<\/strong> \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043a <em>algo<\/em>.<\/p>\n<\/li>\n<li>\n<p><strong>v-for=&#187;name in algos&#187;<\/strong> \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043a <em>name<\/em>.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><a href=\"https:\/\/vuejs.org\/v2\/guide\/syntax.html\" rel=\"noopener noreferrer nofollow\">\u0428\u0430\u0431\u043b\u043e\u043d\u044b Vue<\/a> \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438, \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0434\u0432\u043e\u0439\u043d\u044b\u0435 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438. Vue.js \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 Vue: <\/p>\n<ul>\n<li>\n<p><strong>hash_value<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>name<\/strong><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><a href=\"https:\/\/v3.vuejs.org\/guide\/events.html\" rel=\"noopener noreferrer nofollow\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/a> \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442\u0441\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c (<em>@<\/em>), \u043a\u0430\u043a \u0432 <em>@click=&#187;compute_hash&#187;<\/em>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 Python \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 Vue \u0438 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u043d\u0443\u044e \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443:<\/p>\n<pre><code class=\"python\">from browser import alert, window from javascript import this import hashlib  hashes = {     \"sha-1\": hashlib.sha1,     \"sha-256\": hashlib.sha256,     \"sha-512\": hashlib.sha512, }  Vue = window.Vue  def compute_hash(evt):     value = this().input_text     if not value:         alert(\"You need to enter a value\")         return     hash_object = hashes[this().algo]()     hash_object.update(value.encode())     hex_value = hash_object.hexdigest()     this().hash_value = hex_value  def created():     for name in hashes:         this().algos.append(name)     this().algo = next(iter(hashes))  app = Vue.createApp(     {         \"el\": \"#app\",         \"created\": created,         \"data\": lambda _: {\"hash_value\": \"\", \"algos\": [], \"algo\": \"\", \"input_text\": \"\"},         \"methods\": {\"compute_hash\": compute_hash},     } )  app.mount(\"#app\")<\/code><\/pre>\n<p>\u0414\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u043f\u0440\u0438\u0440\u043e\u0434\u0430 Vue.js \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432 HTML-\u0444\u0430\u0439\u043b\u0435 \u0441 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430\u043c\u0438 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438 Vue. \u041e\u043d\u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u0434\u0435 Python \u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 Vue \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 11 \u0438 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 28\u201335. \u042d\u0442\u0430 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u0437\u043b\u043e\u0432 DOM \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 Vue, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044f <a href=\"https:\/\/vuejs.org\/v2\/guide\/reactivity.html#Declaring-Reactive-Properties\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435<\/a> \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430.<\/p>\n<p>\u042d\u0442\u043e \u0443\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442 \u0447\u0430\u0441\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 DOM \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u0440\u043e\u0434\u0435 <em>document[&#171;some_id&#187;]<\/em>. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Vue \u0438 \u0432\u044b\u0437\u043e\u0432 <em>app.mount()<\/em> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 Vue \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 DOM \u0438 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 JavaScript.<\/p>\n<p>\u0412 Python \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043f\u043e\u043b\u044f\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Vue \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0441\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 Vue \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>javascript.this()<\/em>:<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 14<\/strong> \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <em>this().input_text<\/em>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 21<\/strong> \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 <em>this().hash_value<\/em>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 25<\/strong> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432 \u0441\u043f\u0438\u0441\u043e\u043a <em>this().algos<\/em>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 26<\/strong> \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <em>this().algo<\/em> \u0441 \u043f\u0435\u0440\u0432\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c <em>hashes{}<\/em>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 Vue \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441 Brython \u0432\u044b\u0437\u0432\u0430\u043b\u043e \u0443 \u0432\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441, \u0442\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u0430\u043c \u0441\u0442\u043e\u0438\u0442 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 <a href=\"https:\/\/pypi.org\/project\/vuepy\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c vuepy<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u043d\u044b\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 Python \u0434\u043b\u044f Vue.js \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Brython \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Python \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.<\/p>\n<h3>WebAssembly<\/h3>\n<p><a class=\"anchor\" name=\"webassembly\" id=\"webassembly\"><\/a><\/p>\n<p>\u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/webassembly.org\/\" rel=\"noopener noreferrer nofollow\">WebAssembly<\/a> \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 Brython \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 JavaScript. <strong>WebAssembly<\/strong> \u0438\u043b\u0438 <strong>Wasm<\/strong> \u2014 \u044d\u0442\u043e \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u0432\u0441\u0435\u043c\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u043c\u0438. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 JavaScript \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0446\u0435\u043b\u044c\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432, \u043a\u0430\u043a <a href=\"https:\/\/en.wikipedia.org\/wiki\/C_%28programming_language%29\" rel=\"noopener noreferrer nofollow\">C<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/C%2B%2B\" rel=\"noopener noreferrer nofollow\">C++<\/a> \u0438 <a href=\"https:\/\/www.rust-lang.org\/\" rel=\"noopener noreferrer nofollow\">Rust<\/a>. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 Rust \u0438\u043b\u0438 Wasm, \u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b.<\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f WebAssembly, \u0432\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 Rust \u0438 \u0432\u044b\u0437\u043e\u0432\u0435\u0442\u0435 \u0435\u0435 \u0438\u0437 Python.<\/p>\n<p>\u042d\u0442\u043e \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u0435\u0442 \u043d\u0430 \u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u043f\u043e Rust. \u042d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e Rust \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c \u0441 <a href=\"https:\/\/www.rust-lang.org\/learn\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 Rust<\/a>.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0438\u0442\u0435 \u0441 <a href=\"https:\/\/www.rust-lang.org\/tools\/install\" rel=\"noopener noreferrer nofollow\">\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Rust<\/a> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>rustup<\/em>. \u0414\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 Wasm \u0432\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <a href=\"https:\/\/rustwasm.github.io\/book\/reference\/add-wasm-support-to-crate.html\" rel=\"noopener noreferrer nofollow\"><em>wasm32<\/em>-\u0446\u0435\u043b\u044c<\/a>:<\/p>\n<pre><code class=\"bash\">$ rustup target add wasm32-unknown-unknown<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/doc.rust-lang.org\/cargo\/reference\/index.html\" rel=\"noopener noreferrer nofollow\"><em>cargo<\/em><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Rust:<\/p>\n<pre><code class=\"bash\">$ cargo new --lib op<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043f\u0440\u043e\u0435\u043a\u0442-\u0441\u043a\u0435\u043b\u0435\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <em>op<\/em>. \u0412 \u044d\u0442\u043e\u0439 \u043f\u0430\u043f\u043a\u0435 \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 <em>Cargo.toml<\/em>, \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441\u0431\u043e\u0440\u043a\u0438 Rust, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0440\u0430\u0437\u0434\u0435\u043b <em>[lib]<\/em>:<\/p>\n<pre><code class=\"yaml\">[package] name = \"op\" version = \"0.1.0\" authors = [\"John \"] edition = \"2018\"  [lib] crate-type=[\"cdylib\"]  [dependencies]<\/code><\/pre>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u0435 <em>src\/lib.rs<\/em>, \u0437\u0430\u043c\u0435\u043d\u0438\u0432 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c:<\/p>\n<pre><code class=\"rust\">#[no_mangle] pub extern fn double_first_and_add(x: u32, y: u32) -&gt; u32 {     (2 * x) + y }<\/code><\/pre>\n<p>\u041d\u0430\u0445\u043e\u0434\u044f\u0441\u044c \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0433\u0434\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d <em>Cargo.toml<\/em>, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"bash\">$ cargo build --target wasm32-unknown-unknown<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <em>web<\/em> \u0438 <em>index.html<\/em> \u0432 \u043d\u0435\u043c, \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre><code class=\"xml\">&lt;!-- index.html --&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt;   &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/brython\/3.13.0\/brython.min.js\"&gt;&lt;\/script&gt;   &lt;script src=\"main.py\" type=\"text\/python\"&gt;&lt;\/script&gt; &lt;\/head&gt; &lt;body onload=\"brython()\"&gt;  &lt;form class=\"pure-form\" onsubmit=\"return false;\"&gt;   &lt;h2&gt;Custom Operation using Wasm + Brython&lt;\/h2&gt;   &lt;fieldset&gt;     &lt;legend&gt;Multiply first number by 2 and add result to second number&lt;\/legend&gt;     &lt;input type=\"number\" value=\"0\" id=\"number-1\" placeholder=\"1st number\"            autocomplete=\"off\" required\/&gt;     &lt;input type=\"number\" value=\"0\" id=\"number-2\" placeholder=\"2nd number\"            autocomplete=\"off\" required\/&gt;     &lt;button type=\"submit\" id=\"submit\" class=\"pure-button pure-button-primary\"&gt;         Execute     &lt;\/button&gt;   &lt;\/fieldset&gt; &lt;\/form&gt;  &lt;br\/&gt; &lt;div id=\"result\"&gt;&lt;\/div&gt; &lt;\/body&gt; &lt;\/html&gt;<\/code><\/pre>\n<p>\u0421\u0442\u0440\u043e\u043a\u0430 6 \u0432\u044b\u0448\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 <em>main.py<\/em> \u0438\u0437 \u0442\u043e\u0433\u043e \u0436\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430:<\/p>\n<pre><code class=\"python\">from browser import document, window  double_first_and_add = None  def add_rust_fn(module):   global double_first_and_add   double_first_and_add = module.instance.exports.double_first_and_add  def add_numbers(evt):     nb1 = document[\"number-1\"].value or 0     nb2 = document[\"number-2\"].value or 0     res = double_first_and_add(nb1, nb2)     document[\"result\"].innerHTML = f\"Result: ({nb1} * 2) + {nb2} = {res}\"  document[\"submit\"].bind(\"click\", add_numbers) window.WebAssembly.instantiateStreaming(window.fetch(\"op.wasm\")).then(add_rust_fn)<\/code><\/pre>\n<p>\u0421\u0442\u0440\u043e\u043a\u0438 5 \u0438 7 \u2014 \u044d\u0442\u043e \u0441\u0432\u044f\u0437\u0443\u044e\u0449\u0435\u0435 \u0437\u0432\u0435\u043d\u043e, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0435 Brython \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 Rust <em>double_first_and_add()<\/em>:<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 16<\/strong> \u0447\u0438\u0442\u0430\u0435\u0442 <em>op.wasm<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <em>WebAssembly<\/em>, \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 Wasm-\u0444\u0430\u0439\u043b\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>add_rust_fn()<\/em>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 5<\/strong> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 <em>add_rust_fn()<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u044c Wasm \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 7<\/strong> \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>double_first_and_add()<\/em> \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 <em>double_first_and_add<\/em>, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u0434\u043b\u044f Python.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u0445\u043e\u0434\u044f\u0441\u0442 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 <em>web<\/em> \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 <em>op.wasm<\/em> \u0438\u0437 <em>target\/wasm32-unknown-unknown\/debug\/op.wasm<\/em>:<\/p>\n<pre><code class=\"bash\">$ cp target\/wasm32-unknown-unknown\/debug\/op.wasm web<\/code><\/pre>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0430\u043f\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>\u251c\u2500\u2500 Cargo.lock \u251c\u2500\u2500 Cargo.toml \u251c\u2500\u2500 src \u2502   \u2514\u2500\u2500 lib.rs \u251c\u2500\u2500 target \u2502   ... \u2514\u2500\u2500 web     \u251c\u2500\u2500 index.html     \u251c\u2500\u2500 main.py     \u2514\u2500\u2500 op.wasm<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0430\u043f\u043e\u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0430 Rust, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>cargo new<\/em>. \u0414\u043b\u044f \u044f\u0441\u043d\u043e\u0441\u0442\u0438 <em>target<\/em> \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u043e\u043f\u0443\u0449\u0435\u043d\u043e.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 <em>web<\/em>:<\/p>\n<pre><code class=\"bash\">$ python3 -m http.server Serving HTTP on :: port 8000 (http:\/\/[::]:8000\/) ...<\/code><\/pre>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043f\u043e URL <a href=\"http:\/\/localhost:8000\" rel=\"noopener noreferrer nofollow\"><em>http:\/\/localhost:8000<\/em><\/a>. \u0411\u0440\u0430\u0443\u0437\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ae0\/75e\/6a4\/ae075e6a452513fbc0b7590c8b4dd372.png\" alt=\"WASM Brython\" width=\"626\" height=\"433\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ae0\/75e\/6a4\/ae075e6a452513fbc0b7590c8b4dd372.png\"\/><\/p>\n<div><figcaption>WASM Brython<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c WebAssembly, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0437 JavaScript \u0438\u043b\u0438 Brython. \u0418\u0437-\u0437\u0430 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0445 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0444\u0430\u0439\u043b\u0430 Wasm, \u044d\u0442\u043e \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0432\u0430\u0448\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<blockquote>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>: \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0432 WebAssembly \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c \u0441 \u043f\u043e\u0434\u043a\u0430\u0441\u0442\u043e\u043c <a href=\"https:\/\/realpython.com\/podcasts\/rpp\/154\/\" rel=\"noopener noreferrer nofollow\">The Real Python &#8212; \u0432\u044b\u043f\u0443\u0441\u043a 154<\/a> \u0441 \u0411\u0440\u0435\u0442\u0442\u043e\u043c \u041a\u044d\u043d\u043d\u043e\u043d\u043e\u043c.<\/p>\n<\/blockquote>\n<p>\u0415\u0441\u043b\u0438 JavaScript \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0430\u0448\u0438\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c \u043a \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0442\u043e Rust \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u044d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043a\u043e\u0434 Wasm, \u043b\u0438\u0431\u043e \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438, \u043b\u0438\u0431\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Wasm.<\/p>\n<p>\u0414\u0440\u0443\u0433\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Rust \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 WebAssembly \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 Python \u0438\u043b\u0438 JavaScript. \u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 Python, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u043d\u0430 C \u0438 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u0443\u044e \u0441 Brython. \u0415\u0441\u043b\u0438 \u0442\u0430\u043a\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 Rust, \u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 Wasm \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0435\u0435 \u0441 Brython.<\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432 Brython<\/h2>\n<p><a class=\"anchor\" name=\"brython-core-components\" id=\"brython-core-components\"><\/a><\/p>\n<p><strong>\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/strong> \u2014 \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u044b, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0442\u0440\u0435\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, <strong>A<\/strong>, <strong>B<\/strong> \u0438 <strong>C<\/strong>, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 <strong>A<\/strong>, \u0437\u0430\u0442\u0435\u043c <strong>B<\/strong> \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, <strong>C<\/strong>. \u041a\u0430\u0436\u0434\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0442\u043e\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443.<\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0435\u0431\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 <strong>A<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u043f\u0435\u0440\u0432\u044b\u043c, <strong>B<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d, \u043d\u043e \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u0430 \u0437\u0430\u0442\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d <strong>C<\/strong>. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u0443\u043c\u0430\u0442\u044c \u043e <strong>B<\/strong> \u043a\u0430\u043a \u043e\u0431 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/JavaScript\/Asynchronous\/Introducing#Promises\" rel=\"noopener noreferrer nofollow\">\u043e\u0431\u0435\u0449\u0430\u043d\u0438\u0438<\/a> \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <strong>B<\/strong> \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c\u044b\u0439, \u043e\u043d \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Glossary\/asynchronous\" rel=\"noopener noreferrer nofollow\">\u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c<\/a>. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 <a href=\"https:\/\/realpython.com\/python-async-features\/\" rel=\"noopener noreferrer nofollow\">Getting Started With Async Features in Python<\/a>.<\/p>\n<p>JavaScript \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/JavaScript\/Asynchronous\/Concepts#Threads\" rel=\"noopener noreferrer nofollow\">\u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u043c<\/a> \u0438 \u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u044b \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043a\u043e\u043c\u043c\u0443\u043d\u0438\u043a\u0430\u0446\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 API \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 JavaScript.<\/p>\n<p>\u0421 Brython \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u0447\u0435\u0440\u0435\u0437 \u0440\u044f\u0434 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/javascript.info\/callbacks\" rel=\"noopener noreferrer nofollow\">\u041e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b JavaScript<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/JavaScript\/Asynchronous\/Introducing#Promises\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u043e\u043c\u0438\u0441\u044b JavaScript<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/brython.info\/static_doc\/en\/ajax.html\" rel=\"noopener noreferrer nofollow\"><em>browser.ajax<\/em><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/brython.info\/static_doc\/en\/aio.html\" rel=\"noopener noreferrer nofollow\"><em>browser.aio<\/em><\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e \u043c\u0435\u0440\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f JavaScript \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c \u043e\u0431\u0435\u0449\u0430\u043d\u0438\u044f\u043c\u0438 (\u043f\u0440\u043e\u043c\u0438\u0441\u0430\u043c\u0438) \u0438\u043b\u0438 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Statements\/async_function\" rel=\"noopener noreferrer nofollow\">\u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438<\/a>. \u0412 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u043c\u0438\u0441\u044b \u0438\u0437 Brython \u0438 \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0438 <em>browser.ajax<\/em> \u0438 <em>browser.aio<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e \u043f\u0440\u0438\u0440\u043e\u0434\u0443 JavaScript.<\/p>\n<p><a href=\"https:\/\/docs.python.org\/3\/library\/asyncio.html\" rel=\"noopener noreferrer nofollow\">\u041c\u043e\u0434\u0443\u043b\u044c <em>asyncio<\/em><\/a> \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 CPython \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0438 \u0437\u0430\u043c\u0435\u043d\u0435\u043d \u0432 Brython \u043d\u0430 <em>browser.aio<\/em>.<\/p>\n<h3>\u041f\u0440\u043e\u043c\u0438\u0441\u044b JavaScript \u0432 Brython<\/h3>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0439, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JavaScript-\u043e\u0431\u044a\u0435\u043a\u0442 <em>Promise<\/em> \u0438\u0437 Brython. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u044d\u0442\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0432 \u043e\u043d\u043b\u0430\u0439\u043d-\u043a\u043e\u043d\u0441\u043e\u043b\u0438:<\/p>\n<pre><code class=\"python\">&gt;&gt;&gt; from browser import timer, window &gt;&gt;&gt; def message_in_future(success, error): ...   timer.set_timeout(lambda: success(\"Message in the future\"), 3000) ... &gt;&gt;&gt; def show_message(msg): ...   window.alert(msg) ... &gt;&gt;&gt; window.Promise.new(message_in_future).then(show_message) &lt;Promise object&gt;<\/code><\/pre>\n<p>\u0412 \u0432\u0435\u0431-\u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u044c \u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 Python:<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 1<\/strong> \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 <em>timer<\/em> \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0442\u0430\u0439\u043c-\u0430\u0443\u0442\u0430 \u0438 <em>window<\/em> \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 <em>Promise<\/em>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 2<\/strong> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 <a href=\"https:\/\/javascript.info\/promise-basics\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f<\/a> \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044e  <em>message_in_future()<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043e\u0431\u0435\u0449\u0430\u043d\u0438\u044f \u043f\u043e \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 5<\/strong> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>show_message()<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 8<\/strong> \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u0440\u043e\u043c\u0438\u0441 \u0441 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u0435\u043c, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c \u0441 \u0431\u043b\u043e\u043a\u043e\u043c <em>then<\/em>, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 \u043f\u0440\u043e\u043c\u0438\u0441\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0442\u0430\u0439\u043c-\u0430\u0443\u0442 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u0442 \u0434\u043e\u043b\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0420\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u0435\u0449\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0432\u044b\u0437\u043e\u0432. \u0427\u0435\u0440\u0435\u0437 3 \u0441\u0435\u043a\u0443\u043d\u0434\u044b \u043f\u0440\u043e\u043c\u0438\u0441 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c <em>&#171;Message in the future&#187;<\/em>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f-\u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c <em>message_in_future()<\/em> \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443, \u0442\u043e \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c <em>error()<\/em> \u0441 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u043e\u0432\u043e\u0433\u043e \u0446\u0435\u043f\u043e\u0447\u0435\u0447\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430, <em>.catch()<\/em>, \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <em>Promise<\/em>, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"python\">&gt;&gt;&gt; window.Promise.new(message_in_future).then(show_message).catch(show_message)<\/code><\/pre>\n<p>\u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u043c\u0438\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a7f\/0fb\/cf7\/a7f0fbcf7b5221bb687c458523ec8f77.png\" alt=\"\u041e\u0431\u0435\u0449\u0430\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 Brython\" width=\"841\" height=\"541\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a7f\/0fb\/cf7\/a7f0fbcf7b5221bb687c458523ec8f77.png\"\/><\/p>\n<div><figcaption>\u041e\u0431\u0435\u0449\u0430\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 Brython<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043a\u043e\u0434\u0430 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435, \u0447\u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 <em>Promise<\/em>, \u0430 \u0437\u0430\u0442\u0435\u043c, \u043f\u043e \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043e\u043a\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<\/p>\n<h3>Ajax \u0432 Brython<\/h3>\n<p><a class=\"anchor\" name=\"ajax-in-brython\" id=\"ajax-in-brython\"><\/a><\/p>\n<p> \u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b, \u043a\u043e\u0433\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u0432\u0430\u043b\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438, <a href=\"https:\/\/en.wikipedia.org\/wiki\/I\/O_bound\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043a \u0432\u0432\u043e\u0434\u0443-\u0432\u044b\u0432\u043e\u0434\u0443<\/a>. \u0418\u043c \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438, <a href=\"https:\/\/en.wikipedia.org\/wiki\/CPU-bound\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0443<\/a>. \u0424\u0443\u043d\u043a\u0446\u0438\u044f, <strong>\u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u043a \u0432\u0432\u043e\u0434\u0443-\u0432\u044b\u0432\u043e\u0434\u0443<\/strong> \u2014 \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0442\u0440\u0430\u0442\u0438\u0442 \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0432\u0432\u043e\u0434\u0430 \u0438\u043b\u0438 \u0432\u044b\u0432\u043e\u0434\u0430, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a <strong>\u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0443<\/strong> \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c\u0438. \u0412\u044b\u0437\u043e\u0432 API \u043f\u043e \u0441\u0435\u0442\u0438 \u0438\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u044d\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435, \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0435 \u043a \u0432\u0432\u043e\u0434\u0443-\u0432\u044b\u0432\u043e\u0434\u0443, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043e \u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0443.<\/p>\n<p>\u0412 Brython \u043c\u043e\u0434\u0443\u043b\u044c <em>browser.ajax<\/em> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 HTTP-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <em>get()<\/em> \u0438 <em>post()<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438. \u042d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <em>blocking<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>True<\/em>, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u044b\u0437\u0432\u0430\u0442\u044c <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Methods\/GET\" rel=\"noopener noreferrer nofollow\">HTTP <em>GET<\/em><\/a> \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 <em>ajax.get()<\/em> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0437\u043e\u0432:<\/p>\n<pre><code class=\"python\">ajax.get(url, oncomplete=on_complete)<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c API \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <em>blocking<\/em> \u0432 <em>True<\/em>:<\/p>\n<pre><code class=\"python\">ajax.get(url, blocking=True, oncomplete=on_complete)<\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 Ajax \u0438 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 Ajax:<\/p>\n<pre><code class=\"python\">from browser import ajax, document import javascript  def show_text(req):     if req.status == 200:         log(f\"Text received: '{req.text}'\")     else:         log(f\"Error: {req.status} - {req.text}\")  def log(message):     document[\"log\"].value += f\"{message} \\n\"  def ajax_get(evt):     log(\"Before async get\")     ajax.get(\"\/api.txt\", oncomplete=show_text)     log(\"After async get\")  def ajax_get_blocking(evt):     log(\"Before blocking get\")     try:         ajax.get(\"\/api.txt\", blocking=True, oncomplete=show_text)     except Exception as exc:         log(f\"Error: {exc.__name__} - Did you start a local web server?\")     else:         log(\"After blocking get\")  document[\"get-btn\"].bind(\"click\", ajax_get) document[\"get-blocking-btn\"].bind(\"click\", ajax_get_blocking)<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043a\u043e\u0434 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f: \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0435 \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0435:<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 13<\/strong> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>ajax_get()<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u0438\u0437 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>ajax.get()<\/em>. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <em>ajax.get()<\/em> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e. \u0424\u0443\u043d\u043a\u0446\u0438\u044f <em>ajax_get()<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <em>show_text()<\/em>, \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 <em>oncomplete<\/em>, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 <em>\/api.txt<\/em>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 18<\/strong> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>ajax_get_blocking()<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>ajax.get()<\/em> \u0441 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <em>show_text()<\/em> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 <em>ajax_get_blocking()<\/em>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 <em>Async Get<\/em> \u0438 <em>Blocking Get<\/em> \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u044d\u043a\u0440\u0430\u043d:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/48d\/a1a\/29e\/48da1a29ef738018653e187f60b5768f.png\" alt=\"\u0411\u0440\u0430\u0443\u0437\u0435\u0440 Ajax\" width=\"784\" height=\"753\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/48d\/a1a\/29e\/48da1a29ef738018653e187f60b5768f.png\"\/><\/p>\n<div><figcaption>\u0411\u0440\u0430\u0443\u0437\u0435\u0440 Ajax<\/figcaption><\/div>\n<\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 <em>ajax_get()<\/em> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 API \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 API \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u043e\u043c \u0438\u0437 <em>ajax_get_blocking()<\/em>.<\/p>\n<h3>\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0432\u0432\u043e\u0434-\u0432\u044b\u0432\u043e\u0434 \u0432 Brython<\/h3>\n<p><a class=\"anchor\" name=\"async-io-in-brython\" id=\"async-io-in-brython\"><\/a><\/p>\n<p>\u0421 <a href=\"https:\/\/docs.python.org\/3\/library\/asyncio.html\" rel=\"noopener noreferrer nofollow\"><em>asyncio<\/em><\/a>, Python 3.4 \u043d\u0430\u0447\u0430\u043b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438. \u0412 Python 3.5 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0431\u044b\u043b\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0430 <a href=\"https:\/\/docs.python.org\/3\/whatsnew\/3.5.html#whatsnew-pep-492\" rel=\"noopener noreferrer nofollow\">\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c  <em>async\/await<\/em><\/a>. \u0418\u0437-\u0437\u0430 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0441 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/EventLoop\" rel=\"noopener noreferrer nofollow\">\u0446\u0438\u043a\u043b\u043e\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430<\/a>, Brython \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/EventLoop\" rel=\"noopener noreferrer nofollow\"><em>browser.aio<\/em><\/a> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u043c\u0435\u043d\u044b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c\u0443 <em>asyncio<\/em>.<\/p>\n<p>Brython-\u043c\u043e\u0434\u0443\u043b\u044c <em>browser.aio<\/em> \u0438 Python-\u043c\u043e\u0434\u0443\u043b\u044c <em>asyncio<\/em> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 <em>async<\/em> \u0438 <em>await<\/em> \u0438 \u0438\u043c\u0435\u044e\u0442 \u043e\u0431\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <em>run()<\/em> \u0438 <em>sleep()<\/em>. \u041e\u0431\u0430 \u043c\u043e\u0434\u0443\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u0438\u0445 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0441\u0440\u0435\u0434\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 CPython \u0434\u043b\u044f <em>asyncio<\/em>, \u0438 \u0441\u0440\u0435\u0434\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0434\u043b\u044f <em>browser.aio<\/em>.<\/p>\n<h4>\u0421\u043e\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h4>\n<p><a class=\"anchor\" name=\"coroutines\" id=\"coroutines\"><\/a><\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>run()<\/em> \u0438 <em>sleep()<\/em> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f <a href=\"https:\/\/docs.python.org\/3\/library\/asyncio-task.html#coroutine\" rel=\"noopener noreferrer nofollow\">\u0441\u043e\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c<\/a> (\u043a\u043e\u0440\u0443\u0442\u0438\u043d). \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u043e\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 Brython, \u0432\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043e\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0433\u043e \u0432 <a href=\"https:\/\/docs.python.org\/3\/library\/asyncio-task.html#coroutine\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 CPython<\/a>:<\/p>\n<pre><code class=\"python\">from browser import aio as asyncio import time  async def say_after(delay, what):     await asyncio.sleep(delay)     print(what)  async def main():     print(f\"started at {time.strftime('%X')}\")      await say_after(1, 'hello')     await say_after(2, 'world')      print(f\"finished at {time.strftime('%X')}\")  asyncio.run(main())<\/code><\/pre>\n<p>\u0417\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 <em>import<\/em>, \u043a\u043e\u0434 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0438 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 CPython. \u041e\u043d \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 <em>async<\/em> \u0438 <em>await<\/em>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 <em>run()<\/em> \u0438 <em>sleep()<\/em>:<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 1<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <em>asyncio<\/em> \u043a\u0430\u043a \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c \u0434\u043b\u044f <em>browser.aio<\/em>. \u0425\u043e\u0442\u044f \u044d\u0442\u043e \u0438 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 aio, \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u043e\u0434 \u0431\u043b\u0438\u0436\u0435 \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Python \u0434\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 4<\/strong> \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 <em>say_after()<\/em>. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <em>async<\/em>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 5<\/strong> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>asyncio.sleep()<\/em> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>await<\/em> \u0442\u0430\u043a, \u0447\u0442\u043e \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0441\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f <em>sleep()<\/em>.<\/p>\n<\/li>\n<li>\n<p>\u0412 <strong>\u0441\u0442\u0440\u043e\u043a\u0435 8<\/strong> \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u0441\u043e\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0430\u043c\u0430 \u0434\u0432\u0430\u0436\u0434\u044b \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0441\u043e\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 <em>say_after()<\/em>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 9<\/strong> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <em>run()<\/em> \u2014 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043e\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u2014 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <em>main()<\/em> \u2014 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 <em>aio.run()<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0446\u0438\u043a\u043b \u0441\u043e\u0431\u044b\u0442\u0438\u0439 JavaScript. \u042d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>asyncio.run()<\/em> \u0432 CPython, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0446\u0438\u043a\u043b\u043e\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0439.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434, \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0435\u0433\u043e \u0432 \u043e\u043d\u043b\u0430\u0439\u043d-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 Brython \u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 <em>Run<\/em>. \u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0441\u043d\u0438\u043c\u043a\u0443 \u044d\u043a\u0440\u0430\u043d\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a05\/2b7\/f69\/a052b7f69d3cffee14084a4ef3e6b3d5.png\" alt=\"\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0432\u0432\u043e\u0434-\u0432\u044b\u0432\u043e\u0434 \u0432 Brython\" width=\"1081\" height=\"715\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a05\/2b7\/f69\/a052b7f69d3cffee14084a4ef3e6b3d5.png\"\/><\/p>\n<div><figcaption>\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0432\u0432\u043e\u0434-\u0432\u044b\u0432\u043e\u0434 \u0432 Brython<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442, \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f <em>&#171;hello&#187;<\/em>, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f <em>&#171;world&#187;<\/em>.<\/p>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u043e\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u0445 \u0432 Python \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/realpython.com\/async-io-python\/\" rel=\"noopener noreferrer nofollow\">\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0432\u0432\u043e\u0434-\u0432\u044b\u0432\u043e\u0434 \u0432 Python: \u043f\u043e\u043b\u043d\u043e\u0435 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e<\/a>.<\/p>\n<p>\u041e\u0431\u0449\u0438\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u044b \u043a\u043e \u0432\u0441\u0435\u043c \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u043c, \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u044d\u0442\u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d. \u0412 JavaScript \u0446\u0438\u043a\u043b \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0442\u044a\u0435\u043c\u043b\u0435\u043c\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u0441\u0440\u0435\u0434\u044b, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u0432 CPython \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 <em>asyncio<\/em>.<\/p>\n<p>\u0412\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0431\u044b\u043b \u0446\u0435\u043b\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u043e\u0434 \u0432 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a\u0438\u043c, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Python. \u041f\u0440\u0438 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0441 Brython \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u044f\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>browser.aio<\/em>, \u043a\u0430\u043a \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435.<\/p>\n<h4>\u0412\u0435\u0431-\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h4>\n<p><a class=\"anchor\" name=\"web-specific-functions\" id=\"web-specific-functions\"><\/a><\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 API, \u043a\u0430\u043a \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<pre><code class=\"python\">async def process_get(url):     req = await aio.get(url)<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 <em>async<\/em> \u0438 <em>await<\/em>. \u0424\u0443\u043d\u043a\u0446\u0438\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0443\u044e \u0432\u044b\u0437\u043e\u0432 \u0441 <em>await<\/em>, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u0430\u043a <em>async<\/em>. \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u0432\u044b\u0437\u043e\u0432\u0430 <em>await aio.get(url)<\/em>, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c\u0443 \u0446\u0438\u043a\u043b\u0443 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u043e\u0436\u0438\u0434\u0430\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <em>aio.get()<\/em>. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u044b\u0437\u0432\u0430\u0442\u044c <em>process_get()<\/em>:<\/p>\n<pre><code class=\"python\">aio.run(process_get(\"\/some_api\"))<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <em>aio.run()<\/em> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u043e\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 <em>process_get()<\/em>. \u041e\u043d\u0430 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c\u0430\u044f.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 <em>async<\/em> \u0438 <em>await<\/em>, \u0438 \u043a\u0430\u043a <em>aio.run()<\/em> \u0441 <em>aio.get()<\/em> \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430:<\/p>\n<pre><code class=\"python\">from browser import aio, document import javascript  def log(message):     document[\"log\"].value += f\"{message} \\n\"  async def process_get(url):     log(\"Before await aio.get\")     req = await aio.get(url)     log(f\"Retrieved data: '{req.data}'\")  def aio_get(evt):     log(\"Before aio.run\")     aio.run(process_get(\"\/api.txt\"))     log(\"After aio.run\")  document[\"get-btn\"].bind(\"click\", aio_get)<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 Python 3, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 <em>async<\/em> \u0438 <em>await<\/em>:<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 7<\/strong> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 <em>process_get()<\/em> \u0441 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c <em>async<\/em>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 9<\/strong> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>aio.get()<\/em> \u0441 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c <em>await<\/em>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <em>await<\/em> \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0447\u0442\u043e\u0431\u044b \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u044b\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>async<\/em>.<\/p>\n<\/li>\n<li>\n<p>\u0412 <strong>\u0441\u0442\u0440\u043e\u043a\u0435 14<\/strong> \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>aio.run()<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e <em>async<\/em>-\u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 Python \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>python3 -m http.server<\/em>. \u041e\u043d \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 8000 \u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <em>index.html<\/em>:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/39e\/458\/647\/39e458647a7956ed28e8e0a7390f7226.png\" alt=\"\u0411\u0440\u0430\u0443\u0437\u0435\u0440 Aio\" width=\"1058\" height=\"681\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/39e\/458\/647\/39e458647a7956ed28e8e0a7390f7226.png\"\/><\/p>\n<div><figcaption>\u0411\u0440\u0430\u0443\u0437\u0435\u0440 Aio<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430 \u0441\u043d\u0438\u043c\u043a\u0435 \u044d\u043a\u0440\u0430\u043d\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0448\u0430\u0433\u043e\u0432, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 <em>Async Get<\/em>. \u0421\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f <em>aio<\/em> \u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 <em>async<\/em> \u0438 <em>await<\/em> \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u043e\u0434\u0432\u0438\u0433\u0430\u0435\u0442 JavaScript.<\/p>\n<p><a href=\"\/ru\/article\/872792\/\" rel=\"noopener noreferrer nofollow\">\u0414\u0430\u043b\u0435\u0435..<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/873176\/\"> https:\/\/habr.com\/ru\/articles\/873176\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><a href=\"\/ru\/articles\/872822\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 1<\/a> \u2022 <a href=\"\/ru\/articles\/873174\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 2<\/a> \u2022 <span>\u0427\u0430\u0441\u0442\u044c 3<\/span> \u2022 <a href=\"\/ru\/article\/872792\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 4<\/a><\/p>\n<h2>\u0412\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 JavaScript<\/h2>\n<p><a class=\"anchor\" name=\"interacting-with-javascript\" id=\"interacting-with-javascript\"><\/a><\/p>\n<p>Brython \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 Python-\u043a\u043e\u0434\u0443 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043a\u043e\u0434\u043e\u043c JavaScript. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u2014 \u0434\u043e\u0441\u0442\u0443\u043f \u043a JavaScript \u0438\u0437 Brython. \u041e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0445\u043e\u0442\u044f \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d, \u043d\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d. \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 Python \u0432 JavaScript \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <a href=\"\/ru\/articles\/872792\/#javascript-unit-tests\" rel=\"noopener noreferrer nofollow\">\u042e\u043d\u0438\u0442 \u0422\u0435\u0441\u0442\u044b JavaScript<\/a>.<\/p>\n<h3>JavaScript<\/h3>\n<p><a class=\"anchor\" name=\"javascript\" id=\"javascript\"><\/a><\/p>\n<p>\u0414\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0432\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u043c\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u0434 Python \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0441 \u043a\u043e\u0434\u043e\u043c JavaScript. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043e\u043a\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0432\u044b\u0437\u0432\u0430\u0432 <em>browser.alert()<\/em>.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c <em>alert<\/em> \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0442\u0440\u0435\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445, \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 Brython, \u0430 \u043d\u0435 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 CPython:<\/p>\n<pre><code class=\"python\">&gt;&gt;&gt; import browser &gt;&gt;&gt; browser.alert(\"Real Python\")<\/code><\/pre>\n<p>\u0418\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>window<\/em>:<\/p>\n<pre><code class=\"python\">&gt;&gt;&gt; from browser import window &gt;&gt;&gt; window.alert(\"Real Python\")<\/code><\/pre>\n<p>\u0418\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>this<\/em>:<\/p>\n<pre><code class=\"python\">&gt;&gt;&gt; from javascript import this &gt;&gt;&gt; this().alert(\"Real Python\")<\/code><\/pre>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043d\u043e\u0432\u043e\u043c\u0443 \u0441\u043b\u043e\u044e, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u043c\u0443 Brython, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0443 <em>alert()<\/em> \u0438 <em>window<\/em>, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <em>alert<\/em> \u043a\u0430\u043a <em>browser.window<\/em> \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043a\u0430\u043a <em>javascript.this<\/em>.<\/p>\n<p>\u0412\u043e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 Brython, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c JavaScript:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>\u041c\u043e\u0434\u0443\u043b\u0438<\/p>\n<\/th>\n<th>\n<p>\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442<\/p>\n<\/th>\n<th>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">browser<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u0438 \u043c\u043e\u0434\u0443\u043b\u0438<\/p>\n<\/td>\n<td>\n<p align=\"left\"><em>browser.alert()<\/em><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">browser.document<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u043e\u0441\u0442\u0443\u043f \u043a DOM<\/p>\n<\/td>\n<td>\n<p align=\"left\"><em>document.getElementById(&#171;element-id&#187;)<\/em><\/p>\n<p align=\"left\"><em>document[&#171;element-id&#187;]<\/em><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">browser.html<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u043e\u0437\u0434\u0430\u0435\u0442 HTML-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b<\/p>\n<\/td>\n<td>\n<p align=\"left\"><em>html.H1(&#171;This is the title&#187;)<\/em><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">browser.window<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Window\" rel=\"noopener noreferrer nofollow\"><em>Window<\/em><\/a> \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c<\/p>\n<\/td>\n<td>\n<p align=\"left\"><em>window.navigator <\/em><\/p>\n<p align=\"left\"><em>window.frames<\/em><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><em>javascript.JSON.parse()<\/em><\/p>\n<\/td>\n<td>\n<p align=\"left\">\n<\/td>\n<td>\n<p align=\"left\"><em>javascript.this()<\/em><\/p>\n<p align=\"left\"><em>javascript.JSON.parse()<\/em>  <\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c JavaScript \u0438 API, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0432\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c JavaScript, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 JavaScript \u0438\u0437 Brython:<\/p>\n<pre><code class=\"xml\">&lt;!doctype html&gt; &lt;html&gt;   &lt;head&gt;     &lt;meta charset=\"utf-8\"&gt;     &lt;script         src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/brython\/3.13.0\/brython.js\"&gt;     &lt;\/script&gt;     &lt;script type=\"text\/javascript\"&gt;       function myMessageBox(name) {         window.alert(`Hello ${name}!`);       }     &lt;\/script&gt;   &lt;\/head&gt;   &lt;body onload=\"brython()\"&gt;     &lt;script type=\"text\/python\"&gt;       from browser import window       window.myMessageBox(\"Jon\")     &lt;\/script&gt;   &lt;\/body&gt; &lt;\/html&gt;<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 9<\/strong> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>myMessageBox()<\/em> \u0432 \u0431\u043b\u043e\u043a\u0435 JavaScript.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 17<\/strong> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <em>myMessageBox()<\/em>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0443 \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c JavaScript. \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <a href=\"\/ru\/articles\/873176\/#web-ui-framework\" rel=\"noopener noreferrer nofollow\">\u0424\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Web UI<\/a>, \u0433\u0434\u0435 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 Vue.js, \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c UI-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c.<\/p>\n<h3>\u0412\u0435\u0431-API \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430<\/h3>\n<p><a class=\"anchor\" name=\"browser-web-api\" id=\"browser-web-api\"><\/a><\/p>\n<p>\u0411\u0440\u0430\u0443\u0437\u0435\u0440\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0432\u0435\u0431-API, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u0438\u0437 JavaScript, \u0438 Brython \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0442\u0435\u043c \u0436\u0435 API. \u0412 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0432\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u0435 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440 Base64 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430\u043c\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<p>\u0412\u0435\u0431-API, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u2014 \u044d\u0442\u043e <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Web_Storage_API\" rel=\"noopener noreferrer nofollow\">Web Storage API<\/a>. \u041e\u043d \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0434\u0432\u0430 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Window\/sessionStorage\" rel=\"noopener noreferrer nofollow\"><em>sessionStorage<\/em><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Window\/localStorage\" rel=\"noopener noreferrer nofollow\"><em>localStorage<\/em><\/a><\/p>\n<\/li>\n<\/ol>\n<p>\u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>localStorage<\/em> \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435.<\/p>\n<p>\u041a\u0430\u043a \u0432\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u0440\u0430\u043d\u0435\u0435, \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440 Base64 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0432\u0445\u043e\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0441 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0432 Base64 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u0414\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u043d\u043e \u043e\u0447\u0438\u0449\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0435\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435. \u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 <em>localStorage<\/em> \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430\u043c\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. <em>localStorage<\/em> \u2014 \u044d\u0442\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/Key-value_database\" rel=\"noopener noreferrer nofollow\">\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043a\u043b\u044e\u0447\u0435\u0439 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/a>.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f <em>localStorage<\/em>, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c <em>storage<\/em>. \u0427\u0442\u043e\u0431\u044b \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u043b\u0438\u0436\u0435 \u043a \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0432\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f <em>localStorage<\/em> \u0432 <a href=\"https:\/\/realpython.com\/python-json\/\" rel=\"noopener noreferrer nofollow\">\u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON<\/a>. \u041a\u043b\u044e\u0447\u043e\u043c \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 <em>b64data<\/em>. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u044b \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>load_data()<\/em>:<\/p>\n<pre><code class=\"python\">from browser.local_storage import storage import json, base64  def load_data():     data = storage.get(\"b64data\")     if data:         return json.loads(data)     else:         storage[\"b64data\"] = json.dumps({})         return {}<\/code><\/pre>\n<p><em>load_data()<\/em> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043a\u043e\u0434\u0430 Python. \u041e\u043d\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 JSON \u0438\u0437 <em>localStorage<\/em> \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c Python, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0436\u0438\u0437\u043d\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u0415\u0441\u043b\u0438 \u043e\u043d\u0430 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 <em>b64data<\/em> \u0432 <em>localStorage<\/em>, \u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0434\u043b\u044f \u043a\u043b\u044e\u0447\u0430 <em>b64data<\/em> \u0432 <em>localStorage<\/em> \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 Python, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>load_data()<\/em>. \u041e\u043d \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0431-API <em>localStorage<\/em> \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u043c\u0435\u0441\u0442\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u0430\u043a \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430.<\/p>\n<pre><code class=\"python\">from browser import document, prompt, html, alert from browser.local_storage import storage import json, base64  def load_data():     data = storage.get(\"b64data\")     if data:         return json.loads(data)     else:         storage[\"b64data\"] = json.dumps({})         return {}  def base64_compute(evt):     value = document[\"text-src\"].value     if not value:         alert(\"You need to enter a value\")         return     if value in b64_map:         alert(f\"'{value}' already exists: '{b64_map[value]}'\")         return     b64data = base64.b64encode(value.encode()).decode()     b64_map[value] = b64data     storage[\"b64data\"] = json.dumps(b64_map)     display_map()  def clear_map(evt):     b64_map.clear()     storage[\"b64data\"] = json.dumps({})     document[\"b64-display\"].clear()  def display_map():     if not b64_map:         return     table = html.TABLE(Class=\"pure-table\")     table &lt;= html.THEAD(html.TR(html.TH(\"Text\") + html.TH(\"Base64\")))     table &lt;= (html.TR(html.TD(key) + html.TD(b64_map[key])) for key in b64_map)     base64_display = document[\"b64-display\"]     base64_display.clear()     base64_display &lt;= table     document[\"text-src\"].value = \"\"  b64_map = load_data() display_map() document[\"submit\"].bind(\"click\", base64_compute) document[\"clear-btn\"].bind(\"click\", clear_map)<\/code><\/pre>\n<p>\u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c <em>b64_map<\/em> \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <em>load_data()<\/em> \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0444\u0430\u0439\u043b\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0437\u043e\u0432\u0430 <em>brython()<\/em>. \u041a\u043e\u0433\u0434\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f, \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u0438\u0437 <em>localStorage<\/em>.<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 Base64, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <em>b64_map<\/em> \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/JSON\" rel=\"noopener noreferrer nofollow\">JSON<\/a> \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435. \u041a\u043b\u044e\u0447 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u2014 <em>b64data<\/em>.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u043e \u0432\u0441\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u0432\u0435\u0431-API \u0438\u0437 <em>browser<\/em> \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0443\u0431\u043c\u043e\u0434\u0443\u043b\u0435\u0439. \u0412\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0443 \u043a \u0432\u0435\u0431-API \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432 <a href=\"https:\/\/brython.info\/static_doc\/en\/jsobjects.html\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Brython<\/a>. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0441\u043c. <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0432\u0435\u0431-API<\/a>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <a href=\"https:\/\/brython.info\/console.html\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043d\u0441\u043e\u043b\u044c Brython<\/a> \u0434\u043b\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 \u0432\u0435\u0431-API.<\/p>\n<p>\u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u0432\u0430\u043c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 Python \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0438\u0437 \u0432\u0435\u0431-API. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 Python-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f Base64-\u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 <em>base64.b64encode()<\/em>, \u0445\u043b\u044c\u044f \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JavaScript-\u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/WindowOrWorkerGlobalScope\/btoa\" rel=\"noopener noreferrer nofollow\"><em>btoa()<\/em><\/a>:<\/p>\n<pre><code class=\"python\">&gt;&gt;&gt; from browser import window &gt;&gt;&gt; window.btoa(\"Real Python\") 'UmVhbCBQeXRob24='<\/code><\/pre>\n<p>\u041c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0432 \u043e\u043d\u043b\u0430\u0439\u043d-\u043a\u043e\u043d\u0441\u043e\u043b\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <em>window.btoa()<\/em> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 Brython, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a <em>base64.b64encode()<\/em> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0441 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 Python, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/realpython.com\/cpython-source-code-guide\/\" rel=\"noopener noreferrer nofollow\">CPython<\/a>. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 CPython <em>base64.b64encode()<\/em> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0438\u043f\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 <em>bytearray<\/em>, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a JavaScript-\u0444\u0443\u043d\u043a\u0446\u0438\u044f <em>window.btoa()<\/em> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u0436\u043d\u0435\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 JavaScript-\u0432\u0435\u0440\u0441\u0438\u044e.<\/p>\n<h3>\u0424\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Web UI<\/h3>\n<p><a class=\"anchor\" name=\"web-ui-framework\" id=\"web-ui-framework\"><\/a><\/p>\n<p>\u041f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 UI-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 JavaScript, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <a href=\"https:\/\/angular.io\/\" rel=\"noopener noreferrer nofollow\">Angular<\/a>, <a href=\"https:\/\/reactjs.org\/\" rel=\"noopener noreferrer nofollow\">React<\/a>, <a href=\"https:\/\/vuejs.org\/\" rel=\"noopener noreferrer nofollow\">Vue.js<\/a> \u0438\u043b\u0438 <a href=\"https:\/\/svelte.dev\/\" rel=\"noopener noreferrer nofollow\">Svelte<\/a>, \u0441\u0442\u0430\u043b\u0438 \u0432\u0430\u0436\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 front-end-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430, \u0438 Brython \u043b\u0435\u0433\u043a\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432. \u0412 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Vue.js \u0432\u0435\u0440\u0441\u0438\u0438 3 \u0438 Brython.<\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u0442\u0435, \u2014 \u044d\u0442\u043e \u0444\u043e\u0440\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Hash_function\" rel=\"noopener noreferrer nofollow\">\u0445\u044d\u0448<\/a> \u0441\u0442\u0440\u043e\u043a\u0438. \u0412\u043e\u0442 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0439 HTML-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>Brython Vue.js<\/figcaption><\/div>\n<\/figure>\n<p><em>body<\/em> HTML-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b:<\/p>\n<pre><code class=\"xml\">&lt;!DOCTYPE html &gt; &lt;html&gt;   &lt;head&gt;     &lt;meta charset=\"utf-8\"\/&gt;     &lt;link       rel=\"stylesheet\"       href=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/pure\/3.0.0\/pure-min.min.css\"\/&gt;     &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/vue\/3.5.13\/vue.global.prod.js\"&gt;&lt;\/script&gt;     &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/brython\/3.13.0\/brython.min.js\"&gt;&lt;\/script&gt;     &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/brython\/3.13.0\/brython_stdlib.min.js\"&gt;&lt;\/script&gt;     &lt;script src=\"main.py\" type=\"text\/python\"&gt;&lt;\/script&gt;     &lt;style&gt;       body { padding: 30px; }       [v-cloak] { visibility: hidden; }     &lt;\/style&gt;   &lt;\/head&gt;  &lt;body onload=\"brython(1)\"&gt;   &lt;div id=\"app\"&gt;     &lt;form class=\"pure-form\" onsubmit=\"return false;\"&gt;       &lt;fieldset&gt;         &lt;legend&gt;Hash Calculator&lt;\/legend&gt;         &lt;input type=\"text\" v-model.trim=\"input_text\"                placeholder=\"Text to Encode\" autocomplete=\"off\"\/&gt;         &lt;select v-model=\"algo\" v-cloak&gt;           &lt;option v-for=\"name in algos\" v-bind:value=\"name\"&gt;            &lt;\/option&gt;         &lt;\/select&gt;         &lt;button @click=\"compute_hash\" type=\"submit\"                 class=\"pure-button pure-button-primary\"&gt;Ok&lt;\/button&gt;       &lt;\/fieldset&gt;     &lt;\/form&gt;     &lt;p v-cloak&gt;&lt;\/p&gt;   &lt;\/div&gt; &lt;\/body&gt;<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 Vue, \u0442\u043e \u043d\u0438\u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u043a\u0440\u0430\u0442\u043a\u043e \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435\u0441\u044c \u043a <a href=\"https:\/\/vuejs.org\/v2\/guide\/\" rel=\"noopener noreferrer nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/v3.vuejs.org\/api\/directives.html\" rel=\"noopener noreferrer nofollow\">\u0414\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b Vue.js<\/a> \u2014 \u044d\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <em>v-<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 <a href=\"https:\/\/v3.vuejs.org\/guide\/component-basics.html\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 DOM \u0438 Vue.js<\/a>: <\/p>\n<ul>\n<li>\n<p><strong>v-model.trim=&#187;input_text&#187;<\/strong> \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a <a href=\"https:\/\/v3.vuejs.org\/guide\/migration\/v-model.html#_3-x-syntax\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0434\u0435\u043b\u0438 Vue<\/a> <em>input_text<\/em> \u0438 \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>v-model=&#187;algo&#187;<\/strong> \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043a <em>algo<\/em>.<\/p>\n<\/li>\n<li>\n<p><strong>v-for=&#187;name in algos&#187;<\/strong> \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043a <em>name<\/em>.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><a href=\"https:\/\/vuejs.org\/v2\/guide\/syntax.html\" rel=\"noopener noreferrer nofollow\">\u0428\u0430\u0431\u043b\u043e\u043d\u044b Vue<\/a> \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438, \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0434\u0432\u043e\u0439\u043d\u044b\u0435 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438. Vue.js \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 Vue: <\/p>\n<ul>\n<li>\n<p><strong>hash_value<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>name<\/strong><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><a href=\"https:\/\/v3.vuejs.org\/guide\/events.html\" rel=\"noopener noreferrer nofollow\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/a> \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442\u0441\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c (<em>@<\/em>), \u043a\u0430\u043a \u0432 <em>@click=&#187;compute_hash&#187;<\/em>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 Python \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 Vue \u0438 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u043d\u0443\u044e \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443:<\/p>\n<pre><code class=\"python\">from browser import alert, window from javascript import this import hashlib  hashes = {     \"sha-1\": hashlib.sha1,     \"sha-256\": hashlib.sha256,     \"sha-512\": hashlib.sha512, }  Vue = <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-444902","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/444902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=444902"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/444902\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=444902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=444902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=444902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}