{"id":265817,"date":"2015-09-17T11:35:03","date_gmt":"2015-09-17T07:35:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=265817"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=265817","title":{"rendered":"\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 framework \u043d\u0430 asyncio, aiohttp \u0438 \u043c\u044b\u0441\u043b\u0438 \u043f\u0440\u043e Python3 \u0447\u0430\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u0430\u044f"},"content":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/4dd\/292\/fb4\/4dd292fb4a494a6dbafea76e0c50edbe.jpg\"\/><\/p>\n<p>  \u0413\u043e\u0434\u0430 \u043f\u043e\u043b\u0442\u043e\u0440\u0430 \u043d\u0430\u0437\u0430\u0434, \u0432\u0441\u0442\u0430\u043b \u0432\u043e\u043f\u0440\u043e\u0441 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0441 <code>Python3<\/code>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443\u0436\u0435 \u0441\u0442\u0430\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043d\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0447\u0442\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e <code>Python3<\/code> \u0438 \u0440\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e, \u0432\u0441\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u043e\u0434 \u043d\u0435\u0433\u043e. \u0418 \u0432\u043e \u0432\u0441\u0435\u0445 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u0430\u0445 \u043f\u043e <a href=\"http:\/\/www.opennet.ru\/opennews\/art.shtml?num=41989\">\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u043e\u0439\u043a\u0430<\/a>. \u041d\u043e \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e, \u043f\u043e \u043c\u0435\u0440\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 <code>Python<\/code> \u043c\u043d\u0435 \u0432\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u0442\u0430\u043b \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f <code>Asyncio<\/code> \u0438 \u0441\u043a\u043e\u0440\u0435\u0435 \u0434\u0430\u0436\u0435 \u043d\u0435 <code>Acyncio<\/code> \u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c <code>aiohttp<\/code>. \u0418 \u0441\u043f\u0443\u0441\u0442\u044f \u043a\u0430\u043a\u043e\u0435 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 <code>aiohttp<\/code> \u0432 \u0441\u0442\u0438\u043b\u0435 <code>like django<\/code>. \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0447\u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<p>  <a href=\"#0\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/a><br \/>  <a href=\"#01\"> \u041a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u043d\u0430 \u0431\u0430\u0437\u0435 aiohttp<\/a><br \/>  <a href=\"#1\">1. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/a><br \/>  <a href=\"#2\">2. aiohttp \u0438 jinja2 <\/a><br \/>  <a href=\"#3\">3. aiohttp \u0438 \u0440\u043e\u0443\u0442\u044b<\/a><br \/>  <a href=\"#4\">4. \u0441\u0442\u0430\u0442\u0438\u043a\u0430 \u0438 GET, POST \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442\u044b<\/a><br \/>  <a href=\"#5\">5. Websocket <\/a><br \/>  <a href=\"#6\">6. asyncio \u0438 mongodb, aiohttp, session, middlwere <\/a><br \/>  <a href=\"#7\">7. aiohttp, supervisor, nginx, gunicorn <\/a><br \/>  <a href=\"#8\">8. \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445.<\/a><br \/>  <a href=\"#9\">9.RoadMap<\/a><\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h3><a name=\"0\"><\/a>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u041d\u0430 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443\u0436\u0435 \u0431\u044b\u043b\u0438 \u0433\u043e\u0442\u043e\u0432\u044b \u0434\u043b\u044f <code>Python3<\/code> \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0431\u0438\u0431\u043b\u0438\u0442\u0435\u043a\u0438.<br \/>  \u041f\u043e\u0447\u0438\u0432\u0448\u0438\u0439 <code>PIL<\/code> \u0431\u044b\u043b \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0435\u043d \u043d\u0430 <code>Philow<\/code>, <code>tweppy<\/code> \u043d\u0430 <code>twython<\/code>, <code>python-openid<\/code> \u043d\u0430 <code>python3-openid<\/code> \u0438 \u0442.\u0434. <code>Jinja2<\/code>, <code>xlrt<\/code>, <code>xlwt<\/code> \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0443\u0436\u0435 \u0431\u044b\u043b\u0438 \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 <code>Python3<\/code>.<\/p>\n<p>  \u0413\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u0432\u0441\u0435 \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u044d\u0442\u043e \u0447\u0442\u043e\u0431 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0442\u0434\u0430\u0432\u0430\u043b\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0432\u0438\u0434\u0435 <code>bytes<\/code>:  <\/p>\n<pre><code class=\"python\">def application(env, start_response):     start_response('200 OK', [('Content-Type','text\/html')])     return bytes(&quot;Hello World&quot;, 'utf-8') <\/code><\/pre>\n<p>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e, \u0441 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043f\u043e\u043c\u0443\u0447\u0430\u0442\u0441\u044f:  <\/p>\n<pre><code class=\"python\">py   = sys.version_info py3k = py &gt;= (3, 0, 0) if py3k: \tunicode = str         import io as StringIO         import builtins as __builtin__ else:    import StringIO  <\/code><\/pre>\n<p>  \u041d\u0443 \u0438 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u043e \u043c\u0435\u0440\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c Python3 \u043d\u0435 \u043c\u043e\u0433 \u043d\u0435 \u043f\u0440\u0438\u0432\u043b\u0435\u0447\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 <code>Asyncio<\/code>. \u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432 <code>python3<\/code> \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0434\u0432\u0438\u0436\u043e\u043a. \u041f\u043e\u044f\u0432\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u043f\u0440\u0430\u0432\u0434\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 <code>3.4<\/code> \u0432\u0435\u0440\u0441\u0438\u0438. \u0418 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 <a href=\"http:\/\/www.opennet.ru\/opennews\/art.shtml?num=42952\">3.5<\/a> \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0448\u043b\u0430 \u043d\u0430 \u0434\u043d\u044f\u0445, \u0443 \u043d\u0435\u0433\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u0434\u0430\u0447\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0430\u0445\u0430\u0440, \u043e\u0431 \u044d\u0442\u043e\u043c \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043d\u0430 \u043d\u0435\u043c \u0447\u0442\u043e \u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u044b\u043b\u043e \u0434\u0438\u043a\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e, \u0438 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f \u043f\u043e\u043d\u044f\u043b \u0432\u0441\u0435 \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c <code>tornado<\/code>, <code>gevent<\/code>, <code>twisted<\/code> \u0438\u043b\u0438 \u043e\u0431\u0435\u0440\u0442\u043a\u043e\u0439 \u0432\u043e\u043a\u0440\u0443\u0433 \u0442\u043e\u0433\u043e \u0436\u0435 asynio \u0438 <code>twisted<\/code> \u2014 <a href=\"http:\/\/autobahn.4ws\/python\/\">autobuh<\/a>. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u0438\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u043c. \u041d\u043e \u0432\u0440\u0435\u043c\u044f \u0448\u043b\u043e \u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 <code>asyncio<\/code>  <a href=\"http:\/\/habrahabr.ru\/users\/svetlov\/\" class=\"user_link\">svetlov<\/a> \u0441\u043e\u0437\u0434\u0430\u043b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a <code>aiohttp<\/code>. <code>Aiohttp<\/code> \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>asyncio<\/code> \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0434\u043e \u0443\u0440\u043e\u0432\u043d\u044f <code>flask<\/code> \u0438\u043b\u0438 <code>bottle<\/code>. <\/p>\n<p>  \u041d\u043e \u0441 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u043c\u0438, websocket-\u0430\u043c\u0438, \u0438 \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0438 \u043a\u0430\u043a \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0441 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0446\u0435\u043d\u043e\u0439 \u0437\u0430 \u044d\u0442\u043e, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441 \u043e\u0433\u043b\u044f\u0434\u043a\u043e\u0439 \u043d\u0430 <code>python3.5<\/code>.<br \/>  \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"python\">#python3.4 @asyncio.coroutine def read_data():       data = yield from db.fetch('SELECT . . . ')  #python3.5 async def read_data():       data = await db.fetch('SELECT ...') <\/code><\/pre>\n<p>  \u0418 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0447\u0430\u0442\u043e\u0432, \u0438\u0433\u0440\u0443\u0448\u0435\u043a, \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0439 \u0441 <code>webrtc<\/code> \u0433\u0434\u0435 \u0435\u0441\u0442\u044c <code>websoket<\/code>-\u044b \u043c\u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043b\u0438\u0431\u043e <code>gevent<\/code> \u043b\u0438\u0431\u043e <code>autobah<\/code> \u043b\u0438\u0431\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 <code>node.js<\/code>, \u0432\u0437\u0432\u0435\u0441\u0438\u0432 \u0432\u0441\u0435 \u0437\u0430 \u0438 \u043f\u0440\u043e\u0442\u0438\u0432 \u043e\u0447\u0435\u043d\u044c \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430 <code>aiohttp<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0433\u043e\u0434 \u0443\u0441\u043f\u0435\u043b \u043e\u0431\u0440\u0430\u0441\u0442\u0438 \u0441\u0432\u043e\u0435\u0439 \u044d\u043a\u043e-\u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439, \u0438 \u0440\u044f\u0434\u043e\u043c \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439. \u0418 \u0442\u0430\u043a \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u044d\u0442\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f.<\/p>\n<p>  \u041d\u0430\u0434\u043e \u0435\u0449\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0447\u0442\u043e \u0432 <code>aiohttp<\/code> \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0445\u043e\u0442\u044f \u044d\u0442\u043e \u0438 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e.<\/p>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 <code>aiohttp<\/code> \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0432 \u0441\u0442\u0438\u043b\u0435 <i>like django <\/i>, \u0441 \u043f\u043e\u0445\u043e\u0436\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438. <\/p>\n<p>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 0.1 \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0445 \u0442\u043e \u0431\u0430\u0442\u0430\u0440\u0435\u0435\u043a \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f, \u043d\u043e \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438, \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0434\u0432\u0438\u0433\u043e\u0432. <\/p>\n<h3> <a name=\"01\"><\/a><font color=\"orange\">\u041a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u043d\u0430 \u0431\u0430\u0437\u0435 asyncio \u0438 aiohttp<\/font><\/h3>\n<p>  \u0422\u0443\u0442 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440, \u0447\u0442\u043e\u0431 \u0431\u044b\u043b\u043e \u043e\u0431\u0449\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0434\u0435\u043b \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0443\u043f\u0440\u043e\u0449\u0430\u044e\u0449\u0438\u0445 \u0436\u0438\u0437\u043d\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0432 <code>Python3<\/code>. <br \/>  \u0412\u0441\u0435 \u043d\u0438\u0436\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0434\u0432\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0442\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c \u0442\u044f\u043d\u0443\u0442 <code>aiohttp<\/code> \u0438 \u0431\u0430\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043d\u0430 \u043d\u0435\u043c, \u0438 \u0442\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441 <code>asyncio<\/code>.<\/p>\n<p>  <a href=\"https:\/\/github.com\/quantmind\/pulsar\">Pulsar<\/a> \u2014 <code>framework<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439 <code>asyncio<\/code> \u0438 <code>multiprocessing<\/code>. \u0418\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 <code>django<\/code>, <code>hello world<\/code> \u043d\u0430 \u043d\u0435\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 <code>wsgi<\/code>. \u041d\u0430 <code>github<\/code> \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0447\u0430\u0442\u043e\u0432, \u0430\u0432\u0442\u043e\u0440 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f \u043f\u043e\u043d\u044f\u043b \u043b\u044e\u0431\u0438\u0442 <code>angular.js<\/code>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Pulsar-hello world<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">from pulsar.apps import wsgi  def hello(environ, start_response):     data = b'Hello World!\\n'     response_headers = [ ('Content-type','text\/plain'),  ('Content-Length', str(len(data)))  ]     start_response('200 OK', response_headers)     return [data]  if __name__ == '__main__':     wsgi.WSGIServer(callable=hello).start() <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <a href=\"https:\/\/github.com\/klen\/muffin\">Mufin<\/a> \u2014 <code>framework<\/code> \u0431\u0430\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0439\u0441\u044f \u043d\u0430 <code>aiohttp<\/code>. \u0423 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f \u043f\u043e\u043d\u044f\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e. \u0422\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u043e\u0435 \u043d\u0430 <code>Heroku<\/code> \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0432\u0438\u0434\u0435 \u0447\u0430\u0442\u0430.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Mufin &#8212; hello world<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">import muffin  app = muffin.Application('example')  @app.register('\/', '\/hello\/{name}') def hello(request):     name = request.match_info.get('name', 'anonymous')     return 'Hello %s!' % name <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <a href=\"https:\/\/github.com\/inventive-ninja\/interest\">introduction<\/a> \u2014 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0431\u0430\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0439\u0441\u044f \u043d\u0430 <code>aiohttp<\/code> <code>framework<\/code>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 introduction<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">from interest import Service, http class Service(Service):     @http.get('\/')     def hello(self, request):         return http.Response(text='Hello World!')  service = Service() service.listen(host='127.0.0.1', port=9000, override=True, forever=True) <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <a href=\"https:\/\/github.com\/ChannelOne\/Spanner.py\">Spanner.py<\/a> \u2014 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043c\u0438\u043a\u0440\u043e <code>web-framework<\/code> \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 python \u0434\u043b\u044f \u043b\u044e\u0434\u0435\u0439 :), \u0430\u0432\u0442\u043e\u0440\u0430 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u044f\u043b\u0438 <code>Flask<\/code> \u0438 <code>express.js<\/code>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e <code>asyncio<\/code>. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u043c.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">from webspanner import Spanner app = Spanner()  @app.route('\/') def index(req, res):       res.write(&quot;Hello world&quot;) <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <a href=\"https:\/\/github.com\/pyGrowler\/Growler\">Growler<\/a> \u2014 <code>framework<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439 \u0442\u043e\u043b\u044c\u043a\u043e <code>asyncio<\/code>, \u0430\u0432\u0442\u043e\u0440\u044b \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u0447\u0442\u043e \u0432\u0437\u044f\u043b\u0438 \u0438\u0434\u0435\u0438 <code>node.js<\/code> \u0438 <code>express<\/code>.   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Growler hello world<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">import asyncio from growler import App from growler.middleware import (Logger, Static, Renderer)  loop = asyncio.get_event_loop() app = App('GrowlerServer', loop=loop)  # \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 middleware \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 app.use(Logger()) app.use(Static(path='public'))  @app.get('\/') def index(req, res):     res.render(&quot;home&quot;)  Server = app.create_server(host='127.0.0.1', port=8000) loop.run_forever() <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <a href=\"https:\/\/github.com\/Parkayun\/astrid\">astrid<\/a> \u2014 \u041f\u0440\u043e\u0441\u0442\u043e\u0439 <code>flask<\/code> \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 <code>framework<\/code> \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 <code>aiohttp<\/code>.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">import os from astrid import Astrid from astrid.http import render, response  @app.route('\/') def index_handler(request):     return response(&quot;Hello&quot;)  app.run() <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<h3><a name=\"1\"><\/a><font color=\"orange\">1. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/font> <\/h3>\n<p>  \u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0441\u0430\u043c\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>pip install<\/code> \u0438 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0438 \u0438\u043b\u0438 \u0431\u0430\u0442\u0430\u0440\u0435\u0439\u043a\u0438 \u0438\u0434\u0443\u0449\u0438\u0435 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0430\u0434\u043c\u0438\u043d\u043a\u0430 \u0438\u043b\u0438 \u0432\u0435\u0431-\u043c\u0430\u0433\u0430\u0437\u0438\u043d. \u0418 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0432 \u043a\u0430\u043a\u043e\u043c \u0442\u043e \u043c\u0435\u0441\u0442\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u0438 \u043c\u043e\u0434\u0443\u043b\u0438 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c.<br \/>  \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u043a\u0430\u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0442\u0430\u043a \u0438 \u0441\u0430\u043c\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043f\u0430\u043f\u043a\u0430 \u0441\u043e \u0441\u0442\u0430\u0442\u0438\u043a\u043e\u0439, \u0438 \u043f\u0430\u043f\u043a\u0430 \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438, \u0444\u0430\u0439\u043b\u0438\u043a \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0440\u043e\u0443\u0442\u043e\u0432, \u0438 \u0444\u0430\u0439\u043b\u0438\u043a \u0438\u043b\u0438 \u0444\u0430\u0439\u043b\u0438\u043a\u0438 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u043a \u0431\u0430\u0437\u0435 \u0438 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u044b. <\/p>\n<p>  \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u2014 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <code>pip install<\/code>:  <\/p>\n<pre><code class=\"python\">apps-&gt;       app-&gt;             static             templ             view.py             routes.py      app1-&gt; ...      app2-&gt; ... core-&gt;       core.py       union.py       utils.py  <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u2014 \u0438\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u0448\u0442\u0443\u043a, \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430 \u0441\u0432\u043e\u0439:  <\/p>\n<pre><code class=\"python\">apps-&gt;       app-&gt;             static             templ             view.py             routes.py       app1-&gt; ...       app2-&gt; ... static templ view.py route.py settings.py <\/code><\/pre>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0438\u043a\u043e\u0432 \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0440\u043e\u0443\u0442\u043e\u0432 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0438\u043c:  <\/p>\n<pre><code class=\"python\">from core.union import route  route( '\/',         page,\t\t\t'GET' ) route( '\/db',     test_db,\t\t\t'GET' ) <\/code><\/pre>\n<p>  \u0410 view \u0433\u0434\u0435 \u044d\u0442\u0438 \u0440\u043e\u0443\u0442\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430:  <\/p>\n<pre><code class=\"python\">@asyncio.coroutine def page(request): \treturn templ('index', request, {'key':'val'}) <\/code><\/pre>\n<p> \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u043a\u0440\u043e\u043c\u0435 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b <code>@asyncio.coroutine<\/code> \u0438\u043b\u0438 <code>async def<\/code><\/p>\n<h3><a name=\"2\"><\/a><font color=\"orange\">2. aiohttp, jinja2 \u0438 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a <\/font><\/h3>\n<p>  \u0414\u043b\u044f <code>aiohttp<\/code> \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0434\u0435\u0431\u0430\u0433\u0435\u0440 \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u0434\u043b\u044f <code>jinja2<\/code>. \u0418\u0445 \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.  <\/p>\n<pre><code class=\"python\">pip install aiohttp_jinja2 <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 jinja2 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">import asyncio, jinja2, aiohttp_jinja2  from aiohttp import web         @asyncio.coroutine def page(req):     return aiohttp_jinja2.render_template('index.tpl', req,{'k':'v'})  @asyncio.coroutine def init(loop):     app = web.Application(loop=loop)     aiohttp_jinja2.setup(app, loader=jinja2.FileSystemLoader('.\/'))     app.router.add_route('GET', '\/', page)     srv = yield from loop.create_server(app.make_handler(), '127.0.0.1', 80)     return srv  app = web.Application() loop = asyncio.get_event_loop() loop.run_until_complete(init(loop)) try: loop.run_forever() except KeyboardInterrupt:  pass <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041d\u043e \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0441 \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u0435\u0441\u0442 \u0438 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<pre><code class=\"python\">return templ('index', request, {'key':'val'}) <\/code><\/pre>\n<p>  \u0418 \u0434\u043b\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430. \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a \u0442\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u044c, \u043c\u0435\u0441\u0442 \u0433\u0434\u0435 \u043c\u043e\u0433\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0448\u0430\u043b\u043e\u043d\u044b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0442\u0443\u043a:  <\/p>\n<ol>\n<li>\u0428\u0430\u0431\u043b\u043e\u043d\u044b \u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u0432 \u043f\u0430\u043f\u043a\u0435 <code>templ<\/code> \u0432 \u043a\u043e\u0440\u043d\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/li>\n<li>\u0428\u0430\u0431\u043b\u043e\u043d\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u0435\u0436\u0430\u0442 \u0432 \u043c\u043e\u0434\u0443\u043b\u044f\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438\u043b\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. <\/li>\n<\/ol>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c\u0441\u044f \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043b\u0435\u0436\u0430\u0442 \u0432 \u043a\u043e\u0440\u043d\u0435 \u043a\u0430\u043a\u043e\u0433\u043e \u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>'template'<\/code>. \u0410 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:   <\/p>\n<pre><code class=\"python\">return templ(&quot;apps.app:template&quot;, request, {'key':'val'}) <\/code><\/pre>\n<p>\u0433\u0434\u0435 <code>'app'<\/code> \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0430 <code>'template'<\/code> \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430.<\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0432 \u043c\u0435\u0441\u0442\u0435, \u0433\u0434\u0435 \u043c\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0443\u0442\u0438, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u0443\u0442\u0438, \u043a \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f\u043c \u0433\u0434\u0435 \u043b\u0435\u0436\u0430\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u044b:  <\/p>\n<pre><code class=\"python\">aiohttp_jinja2.setup(app, loader=jinja2.FunctionLoader ( load_templ ) ) <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0431\u0449\u0438\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u044b:<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def get_path(app): \tif type(app) == str: \t\t__import__(app) \t\tapp = sys.modules[app]  \treturn os.path.dirname(os.path.abspath(app.__file__))   def get_templ_path(path): \tmodule_name = ''; module_path = ''; file_name = ''; name_templ = 'default';  \tif ':' in path: \t\tmodule_name, file_name = path.split(&quot;:&quot;, 1) # app.table main \t\tmodule_path = os.path.join( get_path( module_name), &quot;templ&quot;) \telse: \t\tmodule_path = os.path.join( os.getcwd(), 'templ', name_templ) \treturn module_name, module_path, file_name+'.tpl'   def render_templ(t, request, p): \t# \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0447\u0435\u0440\u0435\u0437 = \u0442\u043e p = dict(**p) \treturn aiohttp_jinja2.render_template( t, request, p )   def load_templ(t, **p): \t(module_name, module_path, file_name) = get_templ_path(t) \tdef load_template (module_path, file_name): \t\tpath = os.path.join(module_path, file_name) \t\ttemplate = '' \t\tfilename = path if os.path.exists ( path ) else False \t\tif filename: \t\t\twith open(filename, &quot;rb&quot;) as f: \t\t\t\ttemplate = f.read() \t\treturn template \ttemplate = load_template( module_path, file_name) \tif not template: return 'Template not found {}' .format(t) \treturn template.decode('UTF-8') <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0443\u0442 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439:<br \/>  1) \u041c\u044b \u043f\u0430\u0440\u0441\u0438\u043c \u043d\u0430\u0448 \u043f\u0443\u0442\u044c \u043a \u0448\u0430\u0431\u043b\u043e\u043d\u0443 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>'apps.app:index'<\/code>, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 \u043f\u0443\u0442\u0438 \u0435\u0441\u0442\u044c <code>\u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u0435<\/code> \u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u043d\u0435 \u0438\u0437 \u043a\u043e\u0440\u043d\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0438 \u0442\u043e\u0433\u0434\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0443\u0442\u0435\u0439 \u0438\u0437 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432:  <\/p>\n<pre><code class=\"python\">def get_path(app): \tif type(app) == str:                  # \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u043f\u043e \u0438\u043c\u0435\u043d\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u043c\u044f \u0431\u0443\u0434\u0435\u0442 &quot;news&quot;. \t\t__import__(app)                 # \u043f\u043e \u0438\u043c\u0435\u043d\u0438 &quot;news&quot; \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0430\u043c \u043c\u043e\u0434\u0443\u043b\u044c news \u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 app \t\tapp = sys.modules[app]                  # \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0443\u0442\u044c \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u044e          \treturn os.path.dirname(os.path.abspath(app.__file__))  <\/code><\/pre>\n<p>  2) \u0417\u043d\u0430\u044f \u043f\u0443\u0442\u0438 \u0438 \u0438\u043c\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u0447\u0438\u0442\u0430\u0435\u043c \u0435\u0433\u043e \u0441 \u0434\u0438\u0441\u043a\u0430 (\u0437\u0430\u043c\u0435\u0447\u0443 \u0447\u0442\u043e <code>asyncio<\/code> \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u0441 \u0434\u0438\u0441\u043a\u0430):  <\/p>\n<pre><code class=\"python\">filename = path if os.path.exists ( path ) else False if filename: \twith open(filename, &quot;rb&quot;) as f: \t\ttemplate = f.read() <\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442, \u0447\u0430\u0441\u0442\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044e jinja2 \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432 <a href=\"https:\/\/github.com\/aio-libs\/aiohttp_jinja2#usage\">aiohttp_jinja2<\/a> \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c <code>FileSystemLoader<\/code> \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0435\u043c\u0443 \u043f\u0443\u0442\u044c, \u0438\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0443\u0442\u0435\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<br \/>  <code> aiohttp_jinja2.setup(app, loader=jinja2.FileSystemLoader('\/templ\/')) <\/code><br \/>  \u0410 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <code>FunctionLoader<\/code>: <br \/>  <code> aiohttp_jinja2.setup(app, loader=jinja2.FunctionLoader ( load_templ ) ) <\/code><br \/>  \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f\u0445, \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0438 \u043d\u0435 \u0437\u0430\u0431\u043e\u0442\u0438\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u043c\u0438. \u0410 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 <code>FunctionLoader<\/code> \u043c\u044b \u0438\u0434\u0451\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u043f\u0443\u0442\u044f\u043c, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443 \u043d\u0430\u0441 \u043c\u043e\u0434\u0443\u043b\u0438 \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d. <\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431 \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0432\u044b\u0437\u043e\u0432\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u043e <code>templ<\/code> \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0443\u044e \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u0438 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043c \u0435\u0451 <code>builtins.templ<\/code>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0437 \u043b\u044e\u0431\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 <code>templ<\/code>, \u043d\u0435 \u0434\u0435\u043b\u0430\u044f \u0435\u0433\u043e \u0438\u043c\u043f\u043e\u0440\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e:  <\/p>\n<pre><code class=\"python\">def render_templ(t, request, p): \treturn aiohttp_jinja2.render_template( t, request, p )  builtins.templ = render_templ <\/code><\/pre>\n<p>  <\/p>\n<h4> aiohttp_debugtoolbar<\/h4>\n<p>  <code>aiohttp_debugtoolbar<\/code> \u2014 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e, \u0442\u0430\u043c \u0433\u0434\u0435 \u043c\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 <code>app<\/code>:  <\/p>\n<pre><code class=\"python\">app = web.Application(loop=loop, middlewares=[ aiohttp_debugtoolbar.middleware ]) aiohttp_debugtoolbar.setup(app) <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u043d \u0447\u0435\u0440\u0435\u0437 \u043e\u0447\u0435\u043d\u044c <code>middlwere<\/code>, \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0431\u0443\u0434\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0438\u0436\u0435.<\/p>\n<p>  \u0421\u0430\u043c <code>aiohttp_debugtoolbar<\/code> \u0443 \u043c\u0435\u043d\u044f \u0432\u044b\u0437\u0432\u0430\u043b \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435, \u0438 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0432 \u043d\u0435\u043c \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u043e\u0432: <br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/a64\/b1b\/f1a\/a64b1bf1a56044f0830fa44be5404a16.png\"\/>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0411\u043e\u043b\u044c\u0448\u0435 \u0432 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u0435<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/501\/8e4\/a55\/5018e4a556744ece9942da8e8d63ceae.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/620\/7ba\/4e9\/6207ba4e97bd4850ba3a291a37ce2364.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/3b7\/14d\/3bf\/3b714d3bfa62425cad92c5681da33ee3.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/99f\/b77\/0c0\/99fb770c0b4d4deaa839c809a643d7b1.png\"\/>  <\/div>\n<\/div>\n<p>  <\/p>\n<h3><a name=\"3\"><\/a><font color=\"orange\">3. aiohttp \u0438 \u0440\u043e\u0443\u0442\u044b<\/font> <\/h3>\n<p>  \u0412 <code>aiohttp<\/code> \u0440\u043e\u0443\u0442\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0438\u0437 \u0430\u0434\u0440\u0435\u0441\u0430:  <\/p>\n<pre><code class=\"python\">@asyncio.coroutine def variable_handler(request):     return web.Response( text=&quot;Hello, {}&quot;.format(request.match_info['name']))  app = web.Application() app.router.add_route('GET', '\/{name}', variable_handler) <\/code><\/pre>\n<p>  \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0440\u043e\u0443\u0442\u044b \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u0435 \u0441\u0432\u043e\u0438, \u0432 \u0444\u0430\u0439\u043b\u0438\u043a\u0435 <code>routes.py<\/code>. \u0418 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<pre><code class=\"python\">from core import route  route( '\/',       page,\t\t'GET'  ) route( '\/db',   test_db,\t'POST' ) <\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0441\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0445\u043e\u0442\u044c \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043a\u043e\u0448\u0435\u0440\u043d\u043e. \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>route<\/code> \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0438\u0434:  <\/p>\n<pre><code class=\"python\">def route(t, r, func): \troutes.append((t, r, func)) <\/code><\/pre>\n<p>  \u0412 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0443\u044e \u0438\u0437 \u0441\u0435\u0431\u044f \u0441\u043f\u0438\u0441\u043e\u043a, \u0437\u0430\u043d\u043e\u0441\u0438\u043c \u043a\u043e\u0440\u0442\u0435\u0436\u0430\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u043e\u0443\u0442\u0430. \u0410 \u043f\u043e\u0442\u043e\u043c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0432 \u0444\u043e\u0440\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0432\u0441\u0435\u043c \u043a\u043e\u0440\u0442\u0435\u0436\u0430\u043c \u0438 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0440\u043e\u0443\u0442\u0430:  <\/p>\n<pre><code class=\"python\">for res in routes: \tapp.router.add_route( res[2], res[0], res[1]) <\/code><\/pre>\n<p>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0434 \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0432\u0441\u0435\u043c \u0440\u043e\u0443\u0442\u0430\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u0438 \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u044b <code>routes.py&lt;code&gt;. \u041c\u044b \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a: &lt;source lang=&quot;python&quot;&gt; def union_routes( dir=settings.root ): \tname_app = dir.split(os.path.sep) \tname_app = name_app[len(name_app) - 1] \tfor name in os.listdir(dir): \t\tpath = os.path.join(dir, name)                 if os.path.isdir ( path ) and os.path.isfile ( os.path.join( path, 'routes.py' )): \t\t\tname = name_app+'.'+path[len(dir)+1:]+'.routes' \t\t\tbuiltins.__import__(name, globals=globals()) &lt;\/source&gt;  &lt;h3&gt;&lt;anchor&gt;4&lt;\/anchor&gt;&lt;font color=&quot;orange&quot;&gt;4. \u041e\u0442\u0434\u0430\u0447\u0430 \u0441\u0442\u0430\u0442\u0438\u043a\u0438&lt;\/font&gt; &lt;\/h3&gt; \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u043f\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0441\u0442\u0430\u0442\u0438\u043a\u0443 \u043b\u0443\u0447\u0448\u0435 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e &lt;code&gt;nginx<\/code> \u043d\u043e \u043d\u0430\u0448 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0442\u043e\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u043c\u0435\u0442\u044c \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u043a\u0443.<br \/>  \u0412 <code>aiohttp<\/code> \u0443\u0436\u0435 <a href=\"http:\/\/aiohttp.readthedocs.org\/en\/latest\/web_reference.html#aiohttp.web.UrlDispatcher.add_static\">\u0431\u044b\u043b\u0430<\/a> \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u0434\u0430\u0447\u0438 \u0441\u0442\u0430\u0442\u0438\u043a\u0438 \u043d\u043e \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u0437\u0430\u043c\u0435\u0447\u0435\u043d\u0430 \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u0447\u0435\u043c \u043d\u0430\u0434\u043e \u0438 \u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0441\u0432\u043e\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f.<br \/>  \u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0444\u0430\u0439\u043b\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u043e \u0440\u043e\u0443\u0442\u0443 <code>\/static\/path<\/code>. \u0422\u0435 \u0444\u0430\u0439\u043b\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043f\u0443\u0442\u0438 <code>\/static\/static\/file_name<\/code>, \u0430 \u0444\u0430\u0439\u043b\u044b \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445 <code>\/static\/modul_name\/file_name<\/code>.<\/p>\n<p>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0447\u0442\u043e \u0432\u0441\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0431\u0443\u0434\u0443\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0430\u0445 <code>\/static<\/code> \u043b\u044e\u0431\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0438\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439, \u0441\u043a\u0430\u0436\u0435\u043c <code>\/static\/img\/big_img\/<\/code>.<\/p>\n<p>  \u041d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043c\u044b \u043a\u0430\u043a \u0438 \u0432\u0441\u0435\u0433\u0434\u0430, \u0441 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0422\u0443\u0442 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0434\u043d\u0438\u043c \u0440\u043e\u0443\u0442\u043e\u043c \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432\u0438\u0434\u044b \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0430\u0434\u0440\u0435\u0441\u043e\u0432.  <\/p>\n<pre><code class=\"python\">app.router.add_route('GET', '\/static\/{component:[^\/]+}\/{fname:.+}', union_stat)\t <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>union_stat<\/code> \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0440\u043e\u0443\u0442\u0430 <code>{component:[^\/]+}\/{fname:.+}<\/code> \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438:  <\/p>\n<pre><code class=\"python\">component = request.match_info.get('component', &quot;st&quot;) fname = request.match_info.get('fname', &quot;st&quot;) <\/code><\/pre>\n<p> \u0418 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u0443\u0442\u0438.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e, \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:   <\/p>\n<pre><code class=\"python\">mimetype, encoding = mimetypes.guess_type(filename) if mimetype: headers['Content-Type']       = mimetype if encoding: headers['Content-Encoding'] = encoding <\/code><\/pre>\n<p>\u0418 \u0447\u0438\u0442\u0430\u0435\u043c \u0441\u0430\u043c \u0444\u0430\u0439\u043b \u0441 \u0434\u0438\u0441\u043a\u0430.<br \/>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u043c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0438 \u0441\u0430\u043c \u0444\u0430\u0439\u043b:  <\/p>\n<pre><code class=\"python\">return web.Response( body=content, headers=MultiDict( headers ) ) <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0426\u0435\u043b\u0438\u043a\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a:<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">@asyncio.coroutine def union_stat(request, *args): \tcomponent = request.match_info.get('component', &quot;Anonymous&quot;) \tfname = request.match_info.get('fname', &quot;Anonymous&quot;) \tpath = os.path.join( settings.root, 'apps', component, 'static', fname )  \tif component == 'static': \t\tpath = os.path.join( os.getcwd(), 'static')  \telif not os.path.exists( path ): \t\tpath = os.path.join( os.getcwd(), 'apps', component, 'static' ) \telse: \t\tpath = os.path.join( settings.root, 'apps', component, 'static')   \tcontent, headers = get_static_file(fname, path) \treturn web.Response(body=content, headers=MultiDict( headers ) )   def get_static_file( filename, root ): \timport mimetypes, time  \troot = os.path.abspath(root) + os.sep \tfilename = os.path.abspath(os.path.join(root, filename.strip('\/\\\\'))) \theaders = {}  \tmimetype, encoding = mimetypes.guess_type(filename) \tif mimetype: headers['Content-Type'] = mimetype \tif encoding: headers['Content-Encoding'] = encoding  \tstats = os.stat(filename) \theaders['Content-Length'] = stats.st_size \tfrom core.core import locale_date \tlm = locale_date(&quot;%a, %d %b %Y %H:%M:%S GMT&quot;, time.gmtime(stats.st_mtime), 'en_US.UTF-8') \theaders['Last-Modified'] = str(lm) \theaders['Cache-Control'] = 'max-age=604800' \twith open(filename, 'rb') as f: \t\tcontent = f.read() \t\tf.close() \treturn content, headers <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u0430\u0440\u0443 \u0441\u043b\u043e\u0432 \u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e <code>POST<\/code>, <code>GET<\/code> \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u043f\u0435\u0440\u0435\u0430\u0434\u0440\u0435\u0441\u0430\u0446\u0438\u044e \u0432 <code>aiohttp<\/code>. <code>GET<\/code> \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e   <\/p>\n<pre><code class=\"python\">@asyncio.coroutine def get_get(request):       query = request.GET['query']  @asyncio.coroutine def get_post(request):       data = yield from request.post()       filename = data['mp3'].filename <\/code><\/pre>\n<p>  \u0420\u0435\u0434\u0438\u0440\u0435\u043a\u0442 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 \u0437\u0430\u0434\u0430\u043dy\u043e\u043c\u0443 \u0432 \u0440\u043e\u0443\u0442\u0435 <code>'test'<\/code> c <code>302<\/code> \u043e\u0442\u0432\u0435\u0442\u043e\u043c  <\/p>\n<pre><code class=\"python\">@asyncio.coroutine def redirect(request):       data = yield from request.post()         . . .         url = request.app.router['test'].url()        return web.HTTPFound( url ) <\/code><\/pre>\n<p><a href=\"http:\/\/aiohttp.readthedocs.org\/en\/latest\/web.html#exceptions\">\u0421\u043f\u0438\u0441\u043e\u043a<\/a> \u0432\u0441\u0435\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432.<\/p>\n<h3><a name=\"6\"><\/a><font color=\"orange\">5. aiohttp \u0438 Websocket <\/font><\/h3>\n<p>  \u041e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 <code>aiohttp<\/code> \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432\u0435\u0431\u0441\u043e\u043a\u0435\u0442\u044b, \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u0432\u0430\u0432 \u0432 \u0440\u043e\u0443\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443. \u0411\u0435\u0437 \u043a\u0430\u043a\u0438\u0445 \u0442\u043e \u043b\u0438\u0448\u043d\u0438\u0445 \u043a\u043e\u0441\u0442\u044b\u043b\u0435\u0439.<br \/>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>app.router.add_route('GET',  '\/ws', ws)<\/code>. \u0415\u0441\u043b\u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0440\u043e\u0443\u0442 \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a: <code>route( '\/ws',    ws,   'GET' )<\/code><\/p>\n<p>  \u0421\u0430\u043c\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0432\u0435\u0431\u0441\u043e\u043a\u0435\u0442\u043e\u0432 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u0438 \u0441\u043a\u0430\u0436\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0447\u0430\u0442\u0430 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043a\u043e\u0434\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e.  <\/p>\n<pre><code class=\"python\">def ws(request):     ws = web.WebSocketResponse()     ws.start(request)     while True:         msg = yield from ws.receive()         if msg.tp == MsgType.text:              if msg.data == 'close':                  yield from ws.close()             else:                  ws.send_str(msg.data + '\/answer')         elif msg.tp == aiohttp.MsgType.close: print('websocket connection closed')     return ws\t <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 <code>Node.JS<\/code>, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044f <code>ws<\/code>:  <\/p>\n<pre><code class=\"javascript\">var WebSocketServer = new require('ws'); var clients = {}; var webSocketServer = new WebSocketServer.Server({ port: 8081 }); webSocketServer.on('connection', function(ws) {        var id = Math.random();        clients[id] = ws;        ws.on('message', function(message) {             for (var key in clients) {                      clients[key].send(message);              }       });      ws.on('close', function() {             console.log('\u0421onnection closed ' + id);             delete clients[id];       }); }); <\/code><\/pre>\n<p>  <\/p>\n<h3><a name=\"5\"><\/a><font color=\"orange\"> 6. asyncio \u0438 mongodb, aiohttp, session, middlwere <\/font><\/h3>\n<p>  \u0423 <code>aiohttp<\/code> \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043a\u0430\u043a <code>middlwere<\/code>, \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u043e\u0434 \u044d\u0442\u0438\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0435\u0449\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0433\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u0430 \u043a \u0431\u0430\u0437\u0435.<\/p>\n<p>  \u0423 \u0442\u0430\u043a\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u043a\u0430\u043a <code>flask<\/code> \u0438\u043b\u0438 <code>bootle<\/code> \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0443\u044e \u043b\u0438\u0431\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0432\u0441\u0435\u0433\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u043f\u043e\u0441\u043b\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 <code>bootle<\/code>:  <\/p>\n<pre><code class=\"python\">@bottle.hook('after_request') def enable_cors():     response.headers['Access-Control-Allow-Origin'] = '*' <\/code><\/pre>\n<p>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 <code>aiohttp<\/code>, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0431\u044b\u043b \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d <code>middlwere<\/code>.<br \/>  \u0418\u0442\u0430\u043a \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0431\u0430\u0437\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, <code>request.db<\/code>:  <\/p>\n<pre><code class=\"python\">def test_db(request):         return templ('apps.app:db_test', request, { 'key': request.db.doc.find_one({&quot;_id&quot;:&quot;test&quot;}) }) <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c <code>middlwere<\/code> \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435, \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0443\u0436\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0434\u0435\u0431\u0430\u0433\u0435\u0440\u043e\u043c, \u0441\u0435\u0441\u0441\u0438\u044f\u043c\u0438 \u0438 \u0431\u0430\u0437\u043e\u0439.  <\/p>\n<pre><code class=\"python\">app = web.Application(loop=loop, middlewares=[ aiohttp_debugtoolbar.middleware, db_handler(),  \t\tsession_middleware(EncryptedCookieStorage(b'Secret byte key')) ]) <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041d\u0443 \u0438 \u0441\u0430\u043c\u0430 \u0444\u0430\u0431\u0440\u0438\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def db_handler():     @asyncio.coroutine     def factory(app, handler):         @asyncio.coroutine         def middleware(request):             if request.path.startswith('\/static\/') or request.path.startswith('\/_debugtoolbar'):                 response = yield from handler(request)                 return response             # \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f             db_inf = settings.database             kw = {}             if 'rs' in db_inf: kw['replicaSet'] = db_inf['rs']             from pymongo import MongoClient             mongo = MongoClient( db_inf['host'], 27017)             db = mongo[ db_inf['name'] ]             db.authenticate('admin', settings.database['pass'] )             request.db = db             # \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043c\u0438\u0434\u043b\u0432\u0435\u0440\u043e\u0432 \u0438 \u0434\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f)             response = yield from handler(request)             mongo.close()              # \u044d\u043a\u0437\u0435\u043c\u0435\u043b\u044f\u0440 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0435 \u0432\u0432\u0435\u0440\u0445 \u0434\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438             return response         return middleware     return factory <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041d\u0430 \u0447\u0442\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 <code>middleware<\/code>, \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c, \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0447\u0442\u043e \u0432 <code>request<\/code> \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0430\u0434\u0440\u0435\u0441 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u043a\u0443, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0430\u0434\u0440\u0435\u0441 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u0435\u0431\u0430\u0433\u0435\u0440. \u0427\u0442\u043e\u0431 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u0434\u0435\u0440\u0433\u0430\u0442\u044c \u0431\u0430\u0437\u0443.  <\/p>\n<pre><code class=\"python\">def middleware(request):      if request.path.startswith('\/static\/') or request.path.startswith('\/_debugtoolbar'): <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043a\u043e\u043d\u0435\u043a\u0442\u0438\u043c\u0441\u044f \u043a \u0431\u0430\u0437\u0435:  <\/p>\n<pre><code class=\"python\">mongo = MongoClient( db_inf['host'], 27017) <\/code><\/pre>\n<p>  \u0410 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435:  <\/p>\n<pre><code class=\"python\">mongo.close()  <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u0438 \u043e\u0442 \u0430\u0432\u0442\u043e\u0440\u0430 <code>aiohttp<\/code>  <a href=\"http:\/\/habrahabr.ru\/users\/svetlov\/\" class=\"user_link\">svetlov<\/a> \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0447\u0435\u0440\u0435\u0437 <code>middlwere<\/code>.<\/p>\n<p>  \u041d\u0443 \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043d\u0430\u0434\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0435 \u043a <code>mongodb<\/code>. \u041a \u0431\u043e\u043b\u044c\u0448\u043e\u043c\u0443 \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u043e\u043d \u043f\u043e\u043a\u0430 \u043d\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439, \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0435\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0435\u0441\u0442\u044c <a href=\"https:\/\/bitbucket.org\/mrdon\/asyncio-mongo\/src\/838bc8849e5a30973aef213a54722909906d0032?at=master\">\u0435\u0441\u0442\u044c<\/a> \u043d\u043e \u043e\u043d \u0434\u0430\u0432\u043d\u043e \u0437\u0430\u0431\u0440\u043e\u0448\u0435\u043d \u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0436\u0435\u043b\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0435\u0433\u043e, \u0438 \u0432 \u043d\u0435\u043c \u043d\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 <code>gridFS<\/code>, \u043d\u0435\u0442 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0439 <code>pymongo<\/code> \u0438 \u0442\u0434.<\/p>\n<p>  \u041d\u043e \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435 \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a <code>PyMongo<\/code> \u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043a <code>MongoDB<\/code> \u0434\u043b\u044f <code>Tornado<\/code>, <code>Motor<\/code> \u2014 <a href=\"http:\/\/emptysqua.re\/blog\/all-posts\/\">A. Jesse Jiryu Davis<\/a> \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430\u0434 <a href=\"http:\/\/emptysqua.re\/blog\/motor-and-asyncio-update\/\">\u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0435\u0439<\/a> <code>Asyncio<\/code> \u0432 <code>Motor<\/code>. \u0418 \u0443\u0436\u0435 \u043e\u0431\u0435\u0449\u0430\u0435\u0442 \u044d\u0442\u043e\u0439 \u043e\u0441\u0435\u043d\u044c\u044e \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u044e <code>0.5<\/code> \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 <code>Asyncio<\/code>. <\/p>\n<h3><a name=\"7\"><\/a><font color=\"orange\">7. aiohttp, supervisor, nginx, gunicorn <\/font><\/h3>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c <code>aiohttp<\/code> \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:  <\/p>\n<ol>\n<li><code>aiohttp<\/code> \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0435\u0441\u043b\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439, \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>supervisor<\/code> \u0435c\u043b\u0438 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d. <\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>gunicorn<\/code> \u0438 <code>supervisor<\/code>.<\/li>\n<\/ol>\n<p>  \u0414\u0443\u043c\u0430\u044e \u0434\u043b\u044f \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u0432 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435, \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 <code>nginx<\/code> \u043a\u0430\u043a <code>proxy<\/code>, \u0445\u043e\u0442\u044f <code>gunicorn<\/code> \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u043a\u0435\u0442 \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438.  <\/p>\n<pre><code class=\"nginx\">server {             server_name       test.dev;             location \/ {                        proxy_pass http:\/\/127.0.0.1:8080;            } } <\/code><\/pre>\n<h4>Aiohttp \u0438 supervisor<\/h4>\n<p>  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c supervisor:  <\/p>\n<pre><code class=\"bash\">apt install supervisor <\/code><\/pre>\n<p>  \u0412 <code>\/etc\/supervisor\/conf.d\/<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b <code>aio.conf<\/code> \u0438 \u0432 \u043d\u0435\u043c:  <\/p>\n<pre><code class=\"bash\">[program:aio] command=python3 index.py directory=\/path\/to\/project\/ user=nobody autorestart=true redirect_stderr=true <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430   <\/p>\n<pre><code class=\"bash\">supervisorctl reread &gt;&gt;aio: available &gt;&gt;erp: changed <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043a\u043e\u043d\u0444\u0438\u0433:  <\/p>\n<pre><code class=\"bash\">supervisorctl update &gt;&gt;erp: stopped &gt;&gt;erp: updated process group &gt;&gt;aio: added process group <\/code><\/pre>\n<p>  \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0442\u0430\u0442\u0443\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439:  <\/p>\n<pre><code class=\"bash\">supervisorctl status &gt;&gt;aio          RUNNING    pid 31570, uptime 0:06:49 &gt;&gt;erp          FATAL         Exited too quickly (process log may have details) <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 aiohttp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">import asyncio from aiohttp import web  def test(request):     return {'title': 'Hello' }  @asyncio.coroutine def init(loop):     app = web.Application( loop = loop )     app.router.add_route('GET', '\/', basic_handler, name='index')     handler = app.make_handler()     srv = yield from loop.create_server(handler, '127.0.0.1', 8080)     return srv, handler  loop = asyncio.get_event_loop() srv, handler = loop.run_until_complete(  init( loop )  ) try:  loop.run_forever() except KeyboardInterrupt:             loop.run_until_complete(handler.finish_connections()) <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043d\u0430\u0448\u0438\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c, \u0432 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 <code>sys.path<\/code> \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u043f\u0443\u0442\u0438:  <\/p>\n<pre><code class=\"bash\">#\u043f\u0443\u0442\u044c \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 sys.path.append( settings.root ) #\u043f\u0443\u0442\u044c \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443 sys.path.append( os.path.dirname( __file__ ) ) <\/code><\/pre>\n<p>  <\/p>\n<h4>Aiohttp gunicorn \u0438 supervisor<\/p>\n<h4>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>gunicorn<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0442\u0443\u0442 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>index<\/code> \u043a\u0430\u0440\u0443\u0442\u0438\u043d\u0443, \u0434\u043b\u044f \u0432\u044b\u0437\u0432\u0430.   <\/p>\n<pre><code class=\"python\">from aiohttp import web def index(request):     return web.Response(text=&quot;Hello!&quot;)  app = web.Application() app.router.add_route('GET', '\/', index) <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>gunicorn<\/code> \u043c\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0443\u0431\u0440\u0430\u0432 \u043e\u0442\u0442\u0443\u0434\u0430 \u043a\u0430\u0440\u0443\u0442\u0438\u043d\u0443 \u0438 \u0432\u0441\u0435 \u0447\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0438 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0432\u0435\u0440\u043d\u0443\u0442\u044c <code>app<\/code>.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0430\u043c\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def init_gunicorn(): \tapp = web.Application( middlewares=[ aiohttp_debugtoolbar.middleware, db_handler(),  \t\tsession_middleware(EncryptedCookieStorage(b'Sixteen byte key')) ]) \taiohttp_debugtoolbar.setup(app)  \taiohttp_jinja2.setup(app, loader=jinja2.FunctionLoader ( load_templ ) )  \tunion_routes(os.path.join ( settings.root, 'apps' ) ) \tunion_routes(os.path.join ( os.getcwd(),  'apps' ) )  \tfor res in routes: \t\tapp.router.add_route( res[2], res[0], res[1], name=res[3]) \tapp.router.add_route('GET', '\/static\/{component:[^\/]+}\/{fname:.+}', union_stat)\t \treturn app <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041d\u0443 \u0430 \u0432 \u0444\u0430\u0439\u043b\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c <code>gunicorn<\/code> \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0435\u0451.  <\/p>\n<pre><code class=\"python\">import  sys, os, settings sys.path.append( settings.root ) sys.path.append( os.path.dirname( __file__ ) )  from core.union import init_gunicorn app = init_gunicorn() <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0430\u043c gunicorn \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 \u0441 \u0444\u0430\u0439\u043b\u043e\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"bash\">&gt;&gt; gunicorn app:app -k aiohttp.worker.GunicornWebWorker -b localhost:8080 <\/code><\/pre>\n<p>\u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0447\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>supervisor<\/code>.<\/p>\n<p>  \u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 <code>gunicorn<\/code> \u0447\u0435\u0440\u0435\u0437 <code>supervisor<\/code> \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f, \u0432 \u043f\u0430\u043f\u043a\u0435 \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b gunicorn.conf.py \u0432 \u043d\u0435\u043c:  <\/p>\n<pre><code class=\"bash\">worker_class ='aiohttp.worker.GunicornWebWorker' bind='127.0.0.1:8080' workers=8 reload=True user = &quot;nobody&quot; <\/code><\/pre>\n<p>  \u0412 <code>\/etc\/supervisor\/conf.d\/name.conf<\/code>:  <\/p>\n<pre><code class=\"bash\">[program:name] command=\/usr\/local\/bin\/gunicorn app:app -c \/path\/to\/project\/gunicorn.conf.py directory=\/path\/to\/project\/ user=nobody autorestart=true redirect_stderr=true <\/code><\/pre>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u044b:  <\/p>\n<pre><code class=\"bash\">supervisorctl reread supervisorctl update <\/code><\/pre>\n<h3><a name=\"8\"><\/a><font color=\"orange\">8. \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445.<\/font><\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043a\u0443  <\/p>\n<pre><code class=\"bash\">pip install tao1 <\/code><\/pre>\n<p>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432 \u043d\u0435\u043c \u043f\u0430\u0440\u0443 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0438 \u0442\u0434. <br \/>  \u041a\u043e\u043c\u0430\u043d\u0434\u0430 <code> utils.py -p name <\/code> \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0435\u0451 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c, \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u043c\u0435\u0441\u0442\u043e <code>-p<\/code> \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>--project<\/code> \u0438\u043b\u0438 <code>--startProject<\/code>.<br \/>  \u041a\u043e\u043c\u0430\u043d\u0434\u0443 <code>utils.py -a name<\/code> \u043d\u0430\u0434\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>apps<\/code> \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0432 \u043d\u0435\u0439 \u0442\u0430\u043a \u0436\u0435 \u043e\u043f\u0446\u0438\u044e <code>-a<\/code> \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 <code>--app<\/code> \u0438\u043b\u0438 <code>--startApp<\/code> \ud83d\ude09<\/p>\n<p>  \u0421\u0430\u043c <code>utils.py<\/code> \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e.<br \/>  \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438\u043b\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e.<br \/>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0434\u0443\u043b\u044f <code>argparse<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u043f\u0446\u0438\u0438 \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438:  <\/p>\n<pre><code class=\"python\">parser = argparse.ArgumentParser() parser.add_argument('-project', '-startproject', '-p', type=str, help='Create project' ) parser.add_argument('-app', '-startapp', '-a',         type=str, help='Create app'     ) args = parser.parse_args() <\/code><\/pre>\n<p>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u043f\u0446\u0438\u0439 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0443\u0436\u0435 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0432 \u043d\u0443\u0436\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e:  <\/p>\n<pre><code class=\"python\">import shutil shutil.copytree( os.path.join( os.path.dirname(__file__), 'sites', 'test'), str(args.project) ) <\/code><\/pre>\n<p>  \u0410 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>setup.py<\/code> \u0433\u0434\u0435 \u043c\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432 <br \/>  <a href=\"https:\/\/pypi.python.org\/\">https:\/\/pypi.python.org\/<\/a> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c <code> scripts=['tao1\/core\/utils.py'] <\/code>.<br \/>  \u0422\u043e\u0433\u0434\u0430 \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u0430\u043a\u0435\u0442\u0430 \u0444\u0430\u0439\u043b utils.py \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u0435\u0449\u0435\u043d \u0432 <code>\/usr\/local\/bin\/<\/code> (\u0435\u0441\u043b\u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e ubuntu) \u0438 \u0441\u0442\u0430\u043d\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u043c.<\/p>\n<h3><a name=\"9\"><\/a><font color=\"orange\">9. Road map<\/font><\/h3>\n<p>  <\/p>\n<h4>\u0412\u0435\u0440\u0441\u0438\u044f 0.2 \u2014 0.5 <\/h4>\n<p>  <\/p>\n<ul>\n<li>\u041a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 ( \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e memcached).<\/li>\n<li>\u041c\u0443\u043b\u044c\u0442\u0438\u044f\u0437\u044b\u0447\u043d\u043e\u0441\u0442\u044c. <\/li>\n<li>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u0430\u0440\u043a\u0430\u0441 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043e\u043d-\u043b\u0430\u0439\u043d \u0438\u0433\u0440.<\/li>\n<li>\u041f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0430\u044f \u0430\u0434\u043c\u0438\u043d\u043a\u0430. \u0411\u043e\u043b\u0435\u0435 \u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u0431\u043b\u043e\u0433\u0438 \u0438 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043c\u0430\u0433\u0430\u0437\u0438\u043d.<br \/>   \u041a\u0430\u0440\u043a\u0430\u0441 \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439.   <\/li>\n<\/ul>\n<\/h4>\n<\/h4>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/242541\/\"> http:\/\/habrahabr.ru\/post\/242541\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/4dd\/292\/fb4\/4dd292fb4a494a6dbafea76e0c50edbe.jpg\"\/><\/p>\n<p>  \u0413\u043e\u0434\u0430 \u043f\u043e\u043b\u0442\u043e\u0440\u0430 \u043d\u0430\u0437\u0430\u0434, \u0432\u0441\u0442\u0430\u043b \u0432\u043e\u043f\u0440\u043e\u0441 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0441 <code>Python3<\/code>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443\u0436\u0435 \u0441\u0442\u0430\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043d\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0447\u0442\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e <code>Python3<\/code> \u0438 \u0440\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e, \u0432\u0441\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u043e\u0434 \u043d\u0435\u0433\u043e. \u0418 \u0432\u043e \u0432\u0441\u0435\u0445 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u0430\u0445 \u043f\u043e <a href=\"http:\/\/www.opennet.ru\/opennews\/art.shtml?num=41989\">\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u043e\u0439\u043a\u0430<\/a>. \u041d\u043e \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e, \u043f\u043e \u043c\u0435\u0440\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 <code>Python<\/code> \u043c\u043d\u0435 \u0432\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u0442\u0430\u043b \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f <code>Asyncio<\/code> \u0438 \u0441\u043a\u043e\u0440\u0435\u0435 \u0434\u0430\u0436\u0435 \u043d\u0435 <code>Acyncio<\/code> \u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c <code>aiohttp<\/code>. \u0418 \u0441\u043f\u0443\u0441\u0442\u044f \u043a\u0430\u043a\u043e\u0435 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 <code>aiohttp<\/code> \u0432 \u0441\u0442\u0438\u043b\u0435 <code>like django<\/code>. \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0447\u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<p>  <a href=\"#0\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/a><br \/>  <a href=\"#01\"> \u041a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u043d\u0430 \u0431\u0430\u0437\u0435 aiohttp<\/a><br \/>  <a href=\"#1\">1. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/a><br \/>  <a href=\"#2\">2. aiohttp \u0438 jinja2 <\/a><br \/>  <a href=\"#3\">3. aiohttp \u0438 \u0440\u043e\u0443\u0442\u044b<\/a><br \/>  <a href=\"#4\">4. \u0441\u0442\u0430\u0442\u0438\u043a\u0430 \u0438 GET, POST \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442\u044b<\/a><br \/>  <a href=\"#5\">5. Websocket <\/a><br \/>  <a href=\"#6\">6. asyncio \u0438 mongodb, aiohttp, session, middlwere <\/a><br \/>  <a href=\"#7\">7. aiohttp, supervisor, nginx, gunicorn <\/a><br \/>  <a href=\"#8\">8. \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445.<\/a><br \/>  <a href=\"#9\">9.RoadMap<\/a><\/p>\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-265817","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/265817","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=265817"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/265817\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=265817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=265817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=265817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}