{"id":292804,"date":"2021-01-17T20:15:00","date_gmt":"2021-01-17T12:15:00","guid":{"rendered":"http:\/\/4563.org\/?p=292804"},"modified":"2021-01-17T20:15:00","modified_gmt":"2021-01-17T12:15:00","slug":"python-%e5%85%b3%e4%ba%8e-flask-%e8%a7%86%e5%9b%be%e5%87%bd%e6%95%b0%e4%b8%ad%e9%9c%80%e8%a6%81%e5%a4%9a%e7%ba%bf%e7%a8%8b-or-%e5%a4%9a%e8%bf%9b%e7%a8%8b%e7%9a%84%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=292804","title":{"rendered":"[ Python ]\u5173\u4e8e flask \u89c6\u56fe\u51fd\u6570\u4e2d\u9700\u8981\u591a\u7ebf\u7a0b or \u591a\u8fdb\u7a0b\u7684\u5b9e\u73b0"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  [ Python ]\u5173\u4e8e flask \u89c6\u56fe\u51fd\u6570\u4e2d\u9700\u8981\u591a\u7ebf\u7a0b or \u591a\u8fdb\u7a0b\u7684\u5b9e\u73b0               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : maobukui <\/span>  <span><i><\/i> 2<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h5>\u5bf9\u4e8e flask \u4e00\u76f4\u6709\u4e2a\u7591\u95ee\uff0c\u7f51\u4e0a\u770b\u4e86\u534a\u5929\u6559\u7a0b\uff0c\u6ca1\u627e\u5230\u7b54\u6848\u3002<\/h5>\n<p>flask \u662f\u4e00\u4e2a\u6846\u67b6\uff0c\u89c6\u56fe\u51fd\u6570\u4e2d\u7684\u64cd\u4f5c\u9ed8\u8ba4\u5e94\u8be5\u662f\u5355\u7ebf\u7a0b\u7684\u5427\uff1f\u901a\u8fc7\u6846\u67b6\u5f00\u542f\u591a\u7ebf\u7a0b\u6216\u8005\u591a\u8fdb\u7a0b\uff0c\u90a3\u53ea\u662f\u5bf9\u4e8e\u8bf7\u6c42\u800c\u8a00\uff0c\u5373\u591a\u4e2a\u8bf7\u6c42\u540c\u65f6\u8fc7\u6765\uff0c\u5f00\u542f\u4e86\u5e76\u884c\u5904\u7406\uff0c\u800c\u9488\u5bf9\u67d0\u4e2a\u8bf7\u6c42\uff0c\u5185\u90e8\u60f3\u5f00\u542f\u591a\u7ebf\u7a0b\u6216\u591a\u8fdb\u7a0b\u8be5\u600e\u4e48\u5904\u7406\uff1f \u4f8b\u5982:<\/p>\n<pre><code>@app.route(\"\/login\", methods=[\"GET\"])     def w_login():         handler_A()         handler_B()           return AB <\/code><\/pre>\n<p>\u4e0a\u8ff0\u573a\u666f\u4e0b\uff0c\u5e0c\u671b\u62ff\u5230\u7279\u5b9a\u8bf7\u6c42\u540e\uff0chandler_A \uff08\u8017\u65f6\uff09 \u548c handler_B \u540c\u65f6\u6267\u884c\uff0c\u800c\u4e0d\u662f\u987a\u5e8f\u6267\u884c\u3002<\/p>\n<ul>\n<li>\u662f\u76f4\u63a5\u4f7f\u7528 python \u6807\u51c6\u7684 threading \u6216\u8005 multiprocessing \u5417\uff1f<\/li>\n<li>\u8fd8\u662f\u8bf4\uff0cflask \u9ed8\u8ba4\u5df2\u7ecf\u5728\u5e76\u884c\u5904\u7406\u4e86\uff1f<\/li>\n<\/ul>\n<p>\u611f\u8c22\uff01<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5132179\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : LeeReamond <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u79cd\u60c5\u51b5\u4e0b\u4e0d\u4f1a\u9ed8\u8ba4\u5e76\u884c\uff0c\u5982\u679c\u662f\u7684\u8bdd\u5c5e\u4e8e\u6253\u7834 python \u89e3\u91ca\u89c4\u5219\u7684\u884c\u4e3a\uff0c\u5f88\u98a0\u8986\u3002\u9700\u8981\u7528\u6237\u81ea\u884c\u5904\u7406\u7ebf\u7a0b\uff0c\u5e76\u4e14\u6ce8\u610f gil                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5132180\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lolizeppelin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             HTTP \u670d\u52a1\u5c31\u5e72\u7b26\u5408 http \u534f\u8bae\u7684\u4e8b<\/p>\n<p>\u5199\u6210\u5f02\u6b65\u63a5\u53e3 \u8fd4\u56de\u4efb\u52a1 id <br \/>rpc \u4e22\u5230\u540e\u9762\u670d\u52a1\u5668\u5e72\u8fd9\u4e8b<\/p>\n<p>\u7ed3\u679c\u4ece\u4efb\u52a1 id \u62ff                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5132181\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lewinlan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u60f3\u5f00\u5c31\u5f00\u5457\uff0cjoin \u5c31\u662f\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5132182\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : no1xsyzy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u81ea\u884c\u5904\u7406\u7ebf\u7a0b\u6216\u8005\u8fdb\u7a0b\u3002\u4f46\u4e0d\u63a8\u8350 multiprocessing\uff0c\u8fd9\u4f3c\u4e4e\u4f1a\uff08\u6216\u8005\u5f88\u5bb9\u6613\u4f1a\uff09\u91cd\u5efa\u6574\u4e2a\u6846\u67b6\uff08\u91cd\u65b0 create_app \uff09\u3002<\/p>\n<p>\u8fd8\u53ef\u4ee5 celery \uff08\u4f46\u4f1a\u5f71\u54cd\u6574\u4e2a\u67b6\u6784\u2026\u2026                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5132183\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : iConnect <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8981\u770b\u4f60\u7684\u4e1a\u52a1\u9700\u6c42\uff0c\u8fdb\u7a0b \/\u7ebf\u7a0b\u4e4b\u95f4\u8981\u4e0d\u8981\u4ea4\u6362\u6570\u636e\uff0c\u5b9e\u73b0\u7684\u65b9\u6848\u5c31\u5dee\u522b\u5927\u5f88\u591a\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5132184\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ebingtel <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u628a\u6570\u636e\u653e\u5230\u4efb\u52a1\u961f\u5217\u91cc\u9762 \u8d77\u4e2a\u540e\u53f0\u670d\u52a1\u53bb\u5904\u7406\u2026\u2026\u591a\u7ebf\u7a0b\u53ef\u4ee5\uff0c\u4f46\u662f \u5f88\u96be\u7ba1\u7406\u7ebf\u7a0b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5132185\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xiaolinjia <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u4e00\u822c\u5982\u679c\u662f\u5c0f\u4efb\u52a1\u76f4\u63a5\u5f00\u4e2a threading.Thread \u53bb\u8dd1\uff0c\u9700\u8981\u76d1\u63a7\u7684\u4efb\u52a1\u5c31\u4e0a celery+flower \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5132186\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hanssx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u4e4b\u524d\u4e5f\u6709\u76f8\u5173\u7591\u95ee\uff0c\u540e\u6765\u770b\u5230\u522b\u4eba\u7684\u4ee3\u7801\uff0c\u53ef\u4ee5\u63d0\u4ea4\u5230 ThreadPoolExecutor \u7528\u7ebf\u7a0b\u4f5c\u4e3a\u5904\u7406\u65b9\u6848\uff0c\u6216\u8005\u7528 apscheduler \u505a job \u8c03\u5ea6\uff0c\u518d\u6216\u8005\u7528 celery \u3001dramatic \u3001arq \u7b49\u5f02\u6b65\u6846\u67b6\uff0c\u6216\u8005\u81ea\u5df1\u7528 redis \u6216\u5176\u4ed6\u65b9\u6cd5\u5b9e\u73b0\u961f\u5217\u81ea\u5df1\u5904\u7406\uff1f<br \/>PS\uff1a\u4e0d\u77e5\u9053\u4e3a\u5565\u6211\u8fd9\u8fb9 celery bug \u591a\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>[ Python ]\u5173\u4e8e flas&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/292804"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=292804"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/292804\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=292804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=292804"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=292804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}