{"id":67340,"date":"2021-05-09T00:20:11","date_gmt":"2021-05-08T16:20:11","guid":{"rendered":"http:\/\/www.zhushiyao.com\/?p=67340"},"modified":"2021-05-09T00:27:57","modified_gmt":"2021-05-08T16:27:57","slug":"8eec381889","status":"publish","type":"post","link":"http:\/\/www.zhushiyao.com\/?p=67340","title":{"rendered":"Python \u91cc\u6700\u5f3a\u7684Web\u6846\u67b6\uff0c\u65e9\u5c31\u4e0d\u662fDjango\u548cFlask\u4e86"},"content":{"rendered":"<div class=\"bpp-post-content\">\n<blockquote class=\"js_blockquote_wrap\">\n<section class=\"js_blockquote_digest\">\n<section>\n<section style=\"text-align: left;\"><span style=\"color: #0052ff;\"><strong><span style=\"font-size: 14px;\">\u6765\u81ea\uff1a\u6398\u91d1\uff0c\u4f5c\u8005\uff1aConnorZhang<\/span><\/strong><\/span><\/section>\n<section style=\"text-align: left;\"><span style=\"color: #0052ff;\"><strong><span style=\"font-size: 14px;\">\u94fe\u63a5\uff1ahttps:\/\/juejin.cn\/post\/6944598601674784775<\/span><\/strong><\/span><\/section>\n<\/section>\n<\/section>\n<\/blockquote>\n<p style=\"text-align: left;\"><span style=\"color: inherit; font-size: 15px;\">\u5982\u679c\u8bf4\u8981\u7528 Python \u8fdb\u884c web \u5f00\u53d1\uff0c\u6211\u60f3\u4f60\u4e00\u5b9a\u4f1a\u544a\u8bc9\u6211 \u4f7f\u7528 Flask \u6216\u8005 Django \u518d\u6216\u8005 tornado\uff0c \u7528\u6765\u7528\u53bb\u65e0\u975e\u5c31\u8fd9\u4e09\u79cd\u6846\u67b6\u3002\u53ef\u80fd\u901b github \u591a\u7684\u670b\u53cb\u8fd8\u4f1a\u8bf4\u4e00\u4e2a fastapi\u3002\u4f46\u662f\uff0c\u7687\u4e0a\uff0c\u65f6\u4ee3\u53d8\u4e86\uff0c\u5927\u6e05\u2026 \u4ea1\u4e86\uff01\uff01\uff01<\/span><\/p>\n<section>\n<h2 style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-weight: bold; font-size: 1.2em; border-bottom: 1.5px solid #ec4444; text-align: left;\"><span style=\"font-size: inherit; line-height: inherit; display: inline-block; font-weight: normal; background: #ec4444; color: #ffffff; padding-top: 3px; padding-right: 10px; padding-left: 10px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u901f\u5ea6\u4e3a\u5148<\/span><\/h2>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u5f53\u4e0b\uff0cpython\u90fd\u5df2\u7ecf\u66f4\u65b0\u5230\u4e86 Python3.9.3 \u4e86\uff0c\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u4f7f\u7528\u8fc7 asyncio\u3001\u548c Python3.5 \u65b0\u589e\u7684 async\/await \u8bed\u6cd5\uff0c\u90a3\u8bf4\u660e\u4f60\u53ef\u80fd\u771f\u7684\u662f\u6843\u82b1\u6e90\u4eba\uff0c\u95ee\u4eca\u662f\u4f55\u4e16\uff0c\u4e0d\u77e5\u6709\u6c49\uff0c\u65e0\u8bba\u9b4f\u664b\u4e86<\/p>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u5728\u5f53\u4e0b\uff0c\u57fa\u4e8e async\/await \u8bed\u6cd5\u7684\u5f02\u6b65 Web \u6846\u67b6\u4e5f\u6709\u5f88\u591a\uff0c\u5728 github \u4e0a\u627e\u4e00\u627e\u6bd4\u6bd4\u7686\u662f\u662f\uff0c\u90a3\u7a76\u7adf\u5e94\u8be5\u9009\u54ea\u4e00\u6b3e\u5462\uff1f\u5728 github \u4e0a\u6709\u4e00\u4e2a\u4e13\u95e8\u6d4b\u8bd5\u5404\u79cd\u8bed\u8a00\u5404\u79cd Web \u6846\u67b6\u901f\u5ea6\u7684\u9879\u76ee\uff0c\u6211\u4eec\u6765\u770b\u4e00\u770b\u7b80\u5355\u7684\u6570\u8fd9\u662f\u6240\u6709\u7684 Python Web \u6846\u67b6\u901f\u5ea6\u6d4b\u8bd5\uff0c\u6709\u4eba\u53ef\u80fd\u4f1a\u95ee\u4e3a\u4ec0\u4e48\u4e0d\u662f\u4ece 1 \u5f00\u59cb\u6392\u5e8f\u7684\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u9879\u76ee\u7684\u6d4b\u8bd5\u8fd8\u5305\u542b golang\u3001java\u3001php \u7b49\u4f17\u591a\u8bed\u8a00\u7684 Web \u6846\u67b6\uff0c\u5171\u6709 226 \u6b3e\u3002\u8fd9\u91cc\u6211\u4eec\u53ea\u7528 Python \u6765\u505a\u5bf9\u6bd4\u3002<\/p>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u53ef\u4ee5\u660e\u663e\u7684\u770b\u5230\uff0cflask\u3001django\u3001tornado \u7b49\u8001\u724c\u7684 Python Web \u6846\u67b6\u5df2\u7ecf\u5feb\u8981\u57ab\u5e95\u4e86\u3002<\/p>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">wow\uff0c \u8fd9\u4e2a\u901f\u5ea6\u7edd\u4e86\u3002\u53ef\u80fd\u4f60\u4eec\u8fd8\u5728\u6000\u7591\u8fd9\u4e2a\u901f\u5ea6\u5982\u4f55\u6d4b\u8bd5\u7684\uff0c\u7ed9\u4f60\u4eec\u770b\u4e00\u4e0b\u6d4b\u8bd5\u6e90\u7801\uff1a<\/p>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 5px; background: #1d1f21; color: #c5c8c6; padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important; text-align: left;\"><span style=\"font-size: inherit; line-height: inherit; color: #969896; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0Disable\u00a0all\u00a0logging\u00a0features<\/span><br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0logging<br \/><br \/>logging.disable()<br \/><br \/><br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0flask\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0Flask<br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0meinheld\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0patch<br \/><br \/>patch.patch_all()<br \/><br \/>app\u00a0=\u00a0Flask(__name__)<br \/><br \/><br \/><span style=\"font-size: inherit; line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">@app.route(\"\/\")<\/span><br \/><span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">index<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">()<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">return<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">\"\"<\/span><br \/><br \/><br \/><span style=\"font-size: inherit; line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">@app.route(\"\/user\/&lt;int:id&gt;\",\u00a0methods=[\"GET\"])<\/span><br \/><span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">user_info<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">(id)<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">return<\/span>\u00a0str(id)<br \/><br \/><br \/><span style=\"font-size: inherit; line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">@app.route(\"\/user\",\u00a0methods=[\"POST\"])<\/span><br \/><span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">user<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">()<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">return<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">\"\"<\/span><br \/>\u590d\u5236\u4ee3\u7801<br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0django.http\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0HttpResponse<br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0django.views.decorators.csrf\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0csrf_exempt<br \/><br \/><br \/><span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">index<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">(request)<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">return<\/span>\u00a0HttpResponse(status=<span style=\"font-size: inherit; line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">200<\/span>)<br \/><br \/><br \/><span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">get_user<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">(request,\u00a0id)<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">return<\/span>\u00a0HttpResponse(id)<br \/><br \/><br \/><span style=\"font-size: inherit; line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">@csrf_exempt<\/span><br \/><span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">create_user<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">(request)<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">return<\/span>\u00a0HttpResponse(status=<span style=\"font-size: inherit; line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">200<\/span>)<br \/>\u590d\u5236\u4ee3\u7801<br \/><span style=\"font-size: inherit; line-height: inherit; color: #969896; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0Disable\u00a0all\u00a0logging\u00a0features<\/span><br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0logging<br \/><br \/>logging.disable()<br \/><br \/><br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0tornado.httpserver<br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0tornado.ioloop<br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0tornado.web<br \/><br \/><br \/><span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">class<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">MainHandler<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">(tornado.web.RequestHandler)<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">get<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">(self)<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">pass<\/span><br \/><br \/><br \/><span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">class<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">UserHandler<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">(tornado.web.RequestHandler)<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">post<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">(self)<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">pass<\/span><br \/><br \/><br \/><span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">class<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">UserInfoHandler<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">(tornado.web.RequestHandler)<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">get<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">(self,\u00a0id)<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.write(id)<br \/><br \/><br \/>app\u00a0=\u00a0tornado.web.Application(<br \/>\u00a0\u00a0\u00a0\u00a0handlers=[<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">r\"\/\"<\/span>,\u00a0MainHandler),<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">r\"\/user\"<\/span>,\u00a0UserHandler),<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">r\"\/user\/(d+)\"<\/span>,\u00a0UserInfoHandler),<br \/>\u00a0\u00a0\u00a0\u00a0]<br \/>)<br \/>\u590d\u5236\u4ee3\u7801<br \/><span style=\"font-size: inherit; line-height: inherit; color: #969896; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0Disable\u00a0all\u00a0logging\u00a0features<\/span><br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0logging<br \/><br \/>logging.disable()<br \/><br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0multiprocessing<br \/><br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0sanic\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0Sanic<br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0sanic.response\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0text<br \/><br \/><br \/>app\u00a0=\u00a0Sanic(<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">\"benchmark\"<\/span>)<br \/><br \/><br \/><span style=\"font-size: inherit; line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">@app.route(\"\/\")<\/span><br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">async<\/span>\u00a0<span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">index<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">(request)<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">return<\/span>\u00a0text(<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">\"\"<\/span>)<br \/><br \/><br \/><span style=\"font-size: inherit; line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">@app.route(\"\/user\/&lt;id:int&gt;\",\u00a0methods=[\"GET\"])<\/span><br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">async<\/span>\u00a0<span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">user_info<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">(request,\u00a0id)<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">return<\/span>\u00a0text(str(id))<br \/><br \/><br \/><span style=\"font-size: inherit; line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">@app.route(\"\/user\",\u00a0methods=[\"POST\"])<\/span><br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">async<\/span>\u00a0<span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">user<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">(request)<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">return<\/span>\u00a0text(<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">\"\"<\/span>)<br \/><br \/><br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">if<\/span>\u00a0__name__\u00a0==\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">\"__main__\"<\/span>:<br \/>\u00a0\u00a0\u00a0\u00a0workers\u00a0=\u00a0multiprocessing.cpu_count()<br \/>\u00a0\u00a0\u00a0\u00a0app.run(host=<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">\"0.0.0.0\"<\/span>,\u00a0port=<span style=\"font-size: inherit; line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">3000<\/span>,\u00a0workers=workers,\u00a0debug=<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">False<\/span>,\u00a0access_log=<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">False<\/span>)<br \/>\u590d\u5236\u4ee3\u7801<br \/><\/code><\/pre>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u5c31\u662f\u7b80\u5355\u7684\u4e0d\u505a\u4efb\u4f55\u64cd\u4f5c\uff0c\u53ea\u8fd4\u56de\u54cd\u5e94\uff0c\u867d\u7136\u8fd9\u6837\u6d4b\u8bd5\u6ca1\u6709\u4efb\u4f55\u5b9e\u9645\u610f\u4e49\uff0c\u5728\u6b63\u5e38\u7684\u751f\u4ea7\u73af\u5883\u4e2d\u4e0d\u53ef\u80fd\u4ec0\u4e48\u90fd\u4e0d\u505a\uff0c\u4f46\u662f\u5982\u679c\u6240\u6709\u7684\u6846\u67b6\u90fd\u5982\u6b64\u6d4b\u8bd5\uff0c\u4e5f\u7b97\u662f\u4ece\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u5728\u540c\u4e00\u8d77\u8dd1\u7ebf\u4e0a\u4e86\u5427\u3002<\/p>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">OK\uff0c\u5c31\u8fd9\u4e48\u591a\uff0c\u8bf4\u5230\u8fd9\u91cc\u4f60\u4e5f\u5e94\u8be5\u77e5\u9053\u6211\u60f3\u8981\u8bf4\u7684\u8fd9\u4e2a\u5f02\u6b65\u6846\u67b6\u662f\u8c01\u4e86\uff0c\u6ca1\u9519\uff0c\u6211\u4eec\u4eca\u5929\u7684\u4e3b\u89d2\u5c31\u662f <strong style=\"font-size: inherit; line-height: inherit; color: #ff3502;\">Sanic<\/strong>\u3002<\/p>\n<figure style=\"font-size: inherit; color: inherit; line-height: inherit;\"><img decoding=\"async\" style=\"font-size: inherit; color: inherit; line-height: inherit; display: block; margin-right: auto; margin-left: auto; border-radius: 5px; box-sizing: border-box; border: 0px solid gray;\" title=\"Python \u91cc\u6700\u5f3a\u7684Web\u6846\u67b6\uff0c\u65e9\u5c31\u4e0d\u662fDjango\u548cFlask\u4e86\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2021\/05\/1-1620490811.png\" alt=\"Python \u91cc\u6700\u5f3a\u7684Web\u6846\u67b6\uff0c\u65e9\u5c31\u4e0d\u662fDjango\u548cFlask\u4e86\" \/><\/figure>\n<h2 style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-weight: bold; font-size: 1.2em; border-bottom: 1.5px solid #ec4444; text-align: left;\"><span style=\"font-size: inherit; line-height: inherit; display: inline-block; font-weight: normal; background: #ec4444; color: #ffffff; padding-top: 3px; padding-right: 10px; padding-left: 10px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u4e3a\u4ec0\u4e48\u8981\u7528\u5f02\u6b65 Web \u6846\u67b6\uff1f<\/span><\/h2>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u8fd9\u53ef\u80fd\u662f\u4f17\u591a\u5c0f\u4f19\u4f34\u6700\u5148\u60f3\u5230\u7684\u95ee\u9898\u4e86\u5427\uff1f\u6211\u7528 Django\u3001Flask \u7528\u7684\u597d\u597d\u7684\uff0c\u80fd\u591f\u5b8c\u6210\u6b63\u5e38\u7684\u4efb\u52a1\uff0c\u4e3a\u4ec0\u4e48\u8fd8\u8981\u7528\u5f02\u6b65 Web \u6846\u67b6\u5462\uff1f<\/p>\n<figure style=\"font-size: inherit; color: inherit; line-height: inherit;\"><img decoding=\"async\" style=\"font-size: inherit; color: inherit; line-height: inherit; display: block; margin-right: auto; margin-left: auto; border-radius: 5px; border: 1px solid gray;\" title=\"Python \u91cc\u6700\u5f3a\u7684Web\u6846\u67b6\uff0c\u65e9\u5c31\u4e0d\u662fDjango\u548cFlask\u4e86\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2021\/05\/8-1620490811.png\" alt=\"Python \u91cc\u6700\u5f3a\u7684Web\u6846\u67b6\uff0c\u65e9\u5c31\u4e0d\u662fDjango\u548cFlask\u4e86\" \/><\/figure>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u8bf4\u5230\u8fd9\u91cc\uff0c\u9996\u5148\u6211\u8981\u53cd\u95ee\u4f60\u4f60\u4e00\u4e2a\u95ee\u9898\uff0c\u4f60\u8ba4\u4e3a\u5728 Web \u5f00\u53d1\u8fc7\u7a0b\u4e2d\u6211\u4eec\u6700\u5927\u7684\u654c\u4eba\u662f\u8c01\uff1f\u601d\u8003 5 \u79d2\u949f\uff0c\u7136\u540e\u770b\u770b\u6211\u7684\u56de\u7b54\uff1a<\/p>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u5728 Web \u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u6700\u5927\u7684\u654c\u4eba\u4e0d\u662f\u7528\u6237\uff0c\u800c\u662f\u963b\u585e\uff01<\/p>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u662f\u7684\uff0c\u800c\u5f02\u6b65\u53ef\u4ee5\u6709\u6548\u7684\u89e3\u51b3 \u7f51\u7edc I\/O \u963b\u585e\uff0c\u6587\u4ef6 I\/O \u963b\u585e\u3002\u5177\u4f53\u7684\u963b\u585e\u76f8\u5173\u7684\u6587\u7ae0\u63a8\u8350\u67e5\u770b\u6df1\u5165\u7406\u89e3 Python \u5f02\u6b65\u7f16\u7a0b\u3002\u7531\u4e8e\u5f02\u6b65\u53ef\u4ee5\u63d0\u5347\u6548\u7387\uff0c\u6240\u4ee5\u5bf9\u4e8e Python \u6765\u8bf4\uff0c\u5f02\u6b65\u662f\u6700\u597d\u7684\u63d0\u5347\u6027\u80fd\u7684\u65b9\u5f0f\u4e4b\u4e00\u3002\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48\u8981\u9009\u62e9 \u5f02\u6b65 Web \u6846\u67b6\u7684\u539f\u56e0\u3002<\/p>\n<h2 style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-weight: bold; font-size: 1.2em; border-bottom: 1.5px solid #ec4444; text-align: left;\"><span style=\"font-size: inherit; line-height: inherit; display: inline-block; font-weight: normal; background: #ec4444; color: #ffffff; padding-top: 3px; padding-right: 10px; padding-left: 10px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u751f\u6001\u73af\u5883<\/span><\/h2>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u53ef\u80fd\u6709\u7684\u5c0f\u4f19\u4f34\u8fd8\u662f\u4f1a\u8bf4\uff0c\u4f60\u4e3a\u4ec0\u4e48\u4e0d\u63a8\u8350 falcon \u800c\u662f\u63a8\u8350 Sanic \uff1f\u660e\u660e\u5b83\u7684\u901f\u5ea6\u975e\u5e38\u5feb\uff0c\u8981\u6bd4 Sanic \u5feb\u4e86\u90a3\u4e48\u591a\uff0c\u90a3\u60a8\u770b\u4e00\u4e0b\u4e0b\u9762\u7684\u4ee3\u7801\uff1a<\/p>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 5px; background: #1d1f21; color: #c5c8c6; padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important; text-align: left;\"><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0wsgiref.simple_server\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0make_server<br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0falcon<br \/><br \/><br \/><span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">class<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">ThingsResource<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"line-height: inherit; color: #81a2be; overflow-wrap: inherit !important; word-break: inherit !important;\">on_get<\/span><span style=\"line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">(self,\u00a0req,\u00a0resp)<\/span>:<\/span><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">\"\"\"Handles\u00a0GET\u00a0requests\"\"\"<\/span><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0resp.status\u00a0=\u00a0falcon.HTTP_200\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #969896; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0This\u00a0is\u00a0the\u00a0default\u00a0status<\/span><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0resp.content_type\u00a0=\u00a0falcon.MEDIA_TEXT\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #969896; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0Default\u00a0is\u00a0JSON,\u00a0so\u00a0override<\/span><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0resp.text\u00a0=\u00a0(<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">'nTwo\u00a0things\u00a0awe\u00a0me\u00a0most,\u00a0the\u00a0starry\u00a0sky\u00a0'<\/span><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">'above\u00a0me\u00a0and\u00a0the\u00a0moral\u00a0law\u00a0within\u00a0me.n'<\/span><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">'n'<\/span><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">'\u00a0\u00a0\u00a0\u00a0~\u00a0Immanuel\u00a0Kantnn'<\/span>)<br \/><br \/>app\u00a0=\u00a0falcon.App()<br \/><br \/>things\u00a0=\u00a0ThingsResource()<br \/><br \/>app.add_route(<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">'\/things'<\/span>,\u00a0things)<br \/><br \/><span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">if<\/span>\u00a0__name__\u00a0==\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">'__main__'<\/span>:<br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">with<\/span>\u00a0make_server(<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">''<\/span>,\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #de935f; overflow-wrap: inherit !important; word-break: inherit !important;\">8000<\/span>,\u00a0app)\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #b294bb; overflow-wrap: inherit !important; word-break: inherit !important;\">as<\/span>\u00a0httpd:<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(<span style=\"font-size: inherit; line-height: inherit; color: #b5bd68; overflow-wrap: inherit !important; word-break: inherit !important;\">'Serving\u00a0on\u00a0port\u00a08000...'<\/span>)<br \/><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0httpd.serve_forever()<br \/><\/code><\/pre>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u4e00\u4e2a\u72b6\u6001\u7801\u90fd\u8981\u81ea\u5df1\u5b9a\u4e49\u548c\u586b\u5199\u7684\u6846\u67b6\uff0c\u6211\u60f3\u5b83\u7684\u901f\u5ea6\u5feb\u662f\u503c\u5f97\u80af\u5b9a\u7684\uff0c\u4f46\u662f\u5bf9\u4e8e\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u53c8\u6709\u591a\u5c11\u7684\u5b9e\u7528\u4ef7\u503c\u5462\uff1f\u6240\u4ee5\u6211\u4eec\u9009\u62e9\u6846\u67b6\u5e76\u4e0d\u662f\u8981\u9009\u6700\u5feb\u7684\uff0c\u800c\u662f\u8981\u53c8\u5feb\u53c8\u597d\u7528\u7684\u3002<\/p>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u800c\u5927\u591a\u6570\u6846\u67b6\u5e76\u4e0d\u5177\u5907\u8fd9\u6837\u7684\u751f\u6001\u73af\u5883\uff0c\u8fd9\u5e94\u8be5\u4e5f\u662f\u4e3a\u4ec0\u4e48\u5927\u591a\u6570 Python \u7684 Web \u5f00\u53d1\u8005\u613f\u610f\u9009\u62e9 Django \u3001 Flask \u3001 tornado \u7684\u539f\u56e0\u3002\u5c31\u662f\u56e0\u4e3a\u5b83\u4eec\u7684\u751f\u6001\u76f8\u5bf9\u4e8e\u5176\u4ed6\u6846\u67b6\u8981\u4e30\u5bcc\u592a\u591a\u592a\u591a\u3002<\/p>\n<figure style=\"font-size: inherit; color: inherit; line-height: inherit;\">\u53ef\u662f\uff0c\u5982\u4eca\u4e0d\u4e00\u6837\u4e86\u3002Sanic \u6846\u67b6\uff0c \u4ece 2016 \u5e74 5 \u6708\u5f00\u59cb \u53d1\u5e03\u4e86\u7b2c\u4e00\u7248\u5f02\u6b65 Web \u6846\u67b6\u96cf\u5f62\uff0c\u81f3\u4eca\u5df2\u7ecf\u8d70\u8fc7\u4e86 5 \u4e2a\u5e74\u5934\uff0c\u8fd9 5 \u5e74\uff0c\u7ecf\u8fc7\u4e0d\u65ad\u5730\u6280\u672f\u79ef\u7d2f\uff0cSanic \u5df2\u7ecf\u7531\u4e00\u4e2a\u6b65\u5c65\u8e52\u8dda\u7684\u5c0f\u6846\u67b6\u53d8\u6210\u4e86\u4e00\u4e2a\u5065\u6b65\u5982\u98de\u7684\u7a33\u91cd\u6846\u67b6\u3002<\/figure>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u5728 awesome-sanic \u9879\u76ee\u4e2d\uff0c\u8bb0\u5f55\u4e86\u5927\u91cf\u7684\u7b2c\u4e09\u65b9\u5e93\uff0c\u4f60\u53ef\u4ee5\u627e\u5230\u4efb\u4f55\u5e38\u7528\u7684\u5de5\u5177\uff1a\u4ece API \u5230 Authentication\uff0c\u4ece Development \u5230 Frontend\uff0c\u4ece Monitoring \u5230 ORM\uff0c\u4ece Caching \u5230 Queue\u2026 \u53ea\u6709\u4f60\u60f3\u4e0d\u5230\u7684\uff0c\u6ca1\u6709\u5b83\u6ca1\u6709\u7684\u7b2c\u4e09\u65b9\u62d3\u5c55\u3002<\/p>\n<h2 style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-weight: bold; font-size: 1.2em; border-bottom: 1.5px solid #ec4444; text-align: left;\"><span style=\"font-size: inherit; line-height: inherit; display: inline-block; font-weight: normal; background: #ec4444; color: #ffffff; padding-top: 3px; padding-right: 10px; padding-left: 10px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u751f\u4ea7\u73af\u5883<\/span><\/h2>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u4ee5\u524d\u6211\u5728\u56fd\u5185\u7684\u793e\u533a\u4e2d\u770b\u5230\u8fc7\u4e00\u4e9b\u5c0f\u4f19\u4f34\u5728\u95ee 2020 \u5e74\u4e86\uff0cSanic \u53ef\u4ee5\u7528\u4e8e\u751f\u4ea7\u73af\u5883\u4e86\u5417\uff1f<\/p>\n<figure style=\"font-size: inherit; color: inherit; line-height: inherit;\"><img decoding=\"async\" style=\"font-size: inherit; color: inherit; line-height: inherit; display: block; margin-right: auto; margin-left: auto; border-radius: 5px; border: 1px solid gray;\" title=\"Python \u91cc\u6700\u5f3a\u7684Web\u6846\u67b6\uff0c\u65e9\u5c31\u4e0d\u662fDjango\u548cFlask\u4e86\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2021\/05\/2-1620490811.png\" alt=\"Python \u91cc\u6700\u5f3a\u7684Web\u6846\u67b6\uff0c\u65e9\u5c31\u4e0d\u662fDjango\u548cFlask\u4e86\" \/><\/figure>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u7b54\u6848\u662f\u80af\u5b9a\u7684\uff0c\u7b14\u8005\u4ee5\u4eb2\u8eab\u7ecf\u5386\u6765\u4f5c\u8bc1\uff0c\u4ece19\u5e74\u5e95\uff0c\u6211\u4eec\u5c31\u5df2\u7ecf\u5c06 Sanic \u7528\u4e8e\u751f\u4ea7\u73af\u5883\u4e86\u3002\u5f7c\u65f6\u7684 Sanic \u8fd8\u662f 19.9\uff0c\u7b14\u8005\u7ecf\u5386\u4e86 Sanic 19.9 &#8212; 21.3 \u6240\u6709\u7684 Sanic \u7684\u7248\u672c\uff0c\u773c\u770b\u7740 Sanic \u7684\u751f\u6001\u73af\u5883\u53d8\u5f97\u8d8a\u6765\u8d8a\u68d2\u3002<\/p>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u8fd8\u6709\u4e00\u4e2a\u95ee\u9898\u53ef\u80fd\u4f60\u4eec\u4e0d\u77e5\u9053\uff0cSanic \u5728\u521b\u5efa\u4e4b\u521d\u76ee\u6807\u5c31\u662f\u521b\u5efa\u4e00\u4e2a\u53ef\u4ee5\u7528\u4e8e\u751f\u4ea7\u73af\u5883\u7684 Web \u6846\u67b6\u3002\u53ef\u80fd\u6709\u4e9b\u6846\u67b6\u4f1a\u660e\u786e\u7684\u8bf4\u660e\u6846\u67b6\u4e2d\u81ea\u5e26\u7684 Run \u65b9\u6cd5\u4ec5\u7528\u4e8e\u6d4b\u8bd5\u73af\u5883\uff0c\u4e0d\u8981\u4f7f\u7528\u81ea\u5e26\u7684 Run \u65b9\u6cd5\u7528\u4e8e\u90e8\u7f72\u73af\u5883\u3002\u4f46\u662f Sanic \u6240\u521b\u5efa\u7684\u4e0d\u6b62\u662f\u4e00\u4e2a\u7528\u4e8e\u6d4b\u8bd5\u73af\u5883\u7684\u5e94\u7528\uff0c\u66f4\u662f\u53ef\u4ee5\u76f4\u63a5\u7528\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u7684\u5e94\u7528\u3002\u7701\u53bb\u4e86\u4f7f\u7528 unicorn \u7b49\u90e8\u7f72\u7684\u70e6\u607c\uff01<\/p>\n<h2 style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-weight: bold; font-size: 1.2em; border-bottom: 1.5px solid #ec4444; text-align: left;\"><span style=\"font-size: inherit; line-height: inherit; display: inline-block; font-weight: normal; background: #ec4444; color: #ffffff; padding-top: 3px; padding-right: 10px; padding-left: 10px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u6587\u6863\u5b8c\u5584<\/span><\/h2>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u60f3\u5fc5\u5927\u591a\u6570 Python \u7684 Web \u5f00\u53d1\u8005 \u5b66\u7684\u7b2c\u4e00\u4e2a\u6846\u67b6\u5c31\u662f Flask \u6216\u8005 Django \u5427\uff0c\u5c24\u5176\u662f Django \u7684\u6587\u6863\uff0c\u6211\u60f3\u5927\u591a\u6570\u5c0f\u4f19\u4f34\u770b\u4e86\u90fd\u4f1a\u5fc3\u585e\u3002\u56e0\u4e3a\u65e7\u7684\u7248\u672c\u6709\u4e2d\u6587\uff0c\u4f46\u662f\u65b0\u7684\u7248\u672c\uff0c\u5c24\u5176\u662f\u65b0\u7279\u6027\uff0c\u5b8c\u5168\u6ca1\u6709\u4efb\u4f55\u4e2d\u6587\u6587\u6863\u4e86\uff01\uff01\uff01\uff01\u8fd9\u5bf9\u4e8e\u5173\u6ce8 Django \u53d1\u5c55\u4f46\u82f1\u6587\u53c8\u4e0d\u662f\u5f3a\u9879\u7684\u540c\u5b66\u6765\u8bf4\uff0c\u7b80\u76f4\u82e6\u4e0d\u582a\u8a00\u3002<\/p>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u4f46 Sanic \u62e5\u6709\u5b8c\u5584\u7684 \u4e2d\u6587\u7528\u6237\u6307\u5357 \u548c API \u6587\u6863\uff0c\u8fd9\u4e9b\u90fd\u662f\u7531\u8d21\u732e\u8005\u81ea\u4e3b\u53d1\u8d77\u7684\uff0c\u5b98\u65b9\u627f\u8ba4\u7684\u6587\u6863\uff0c\u7531\u7ffb\u8bd1\u8005\u8fdb\u884c\u7ffb\u8bd1\u8d21\u732e\uff0c\u7531 Sanic \u5b98\u65b9\u56e2\u961f\u8fdb\u884c\u53d1\u5e03\u3002\u6216\u8bb8\u6709\u7684\u5c0f\u4f19\u4f34\u4f1a\u8bf4 Flask \u4e5f\u6709\u5b8c\u5584\u7684\u4e2d\u6587\u6587\u6863\uff0c\u4f46\u662f\u90a3\u662f\u5728\u4e0d\u540c\u7684\u7ad9\u70b9\u4e0a\u7684\uff0cSanic \u7684\u6240\u6709\u6587\u6863\u90fd\u6709 Sanic \u5b98\u65b9\u8fdb\u884c\u53d1\u5e03\u652f\u6301\u3002\u4e14\u76ee\u524d Sanic \u8fd8\u5728\u6301\u7eed\u652f\u6301 \u97e9\u8bed\u3001\u8461\u8404\u7259\u8bed\u7b49\u66f4\u591a\u7684\u8bed\u79cd\u3002<\/p>\n<figure style=\"font-size: inherit; color: inherit; line-height: inherit;\"><img decoding=\"async\" style=\"font-size: inherit; color: inherit; line-height: inherit; display: block; margin-right: auto; margin-left: auto; border-radius: 5px; border: 1px solid gray;\" title=\"Python \u91cc\u6700\u5f3a\u7684Web\u6846\u67b6\uff0c\u65e9\u5c31\u4e0d\u662fDjango\u548cFlask\u4e86\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2021\/05\/6-1620490811-1.png\" alt=\"Python \u91cc\u6700\u5f3a\u7684Web\u6846\u67b6\uff0c\u65e9\u5c31\u4e0d\u662fDjango\u548cFlask\u4e86\" \/><\/figure>\n<h2 style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-weight: bold; font-size: 1.2em; border-bottom: 1.5px solid #ec4444; text-align: left;\"><span style=\"font-size: inherit; line-height: inherit; display: inline-block; font-weight: normal; background: #ec4444; color: #ffffff; padding-top: 3px; padding-right: 10px; padding-left: 10px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u793e\u533a\u6307\u5bfc<\/span><\/h2>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u548c\u5176\u4ed6\u6846\u67b6\u4e0d\u540c\uff0c\u60a8\u6216\u8bb8\u80fd\u591f\u5728\u767e\u5ea6\u4e0a\u627e\u5230\u8bba\u575b\u3001\u9891\u9053\u7b49\uff0c\u4f46\u8fd9\u4e9b\u90fd\u662f\u7ecf\u8fc7\u672c\u5730\u6c49\u5316\u7684\uff0c\u8fd0\u8425\u8005\u5f80\u5f80\u5e76\u4e0d\u662f\u5b98\u65b9\uff0c\u4e14\u5176\u4e2d\u5939\u6742\u4e86\u5f88\u591a\u5e7f\u544a\u3002\u5f88\u663e\u7136\uff0c\u5982\u679c\u662f\u5b98\u65b9\u8fd0\u8425\u7684\u4e0d\u53ef\u80fd\u5141\u8bb8\u8fd9\u79cd\u60c5\u51b5\u51fa\u73b0\u3002<\/p>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">Sanic \u4e0d\u540c\u4e8e\u5176\u4ed6\u7684\u793e\u533a\uff0c\u6240\u6709\u7684\u8bba\u575b\u3001\u9891\u9053\u5b8c\u5168\u7531\u5b98\u65b9\u8fd0\u8425\uff0c\u5728\u8fd9\u91cc\uff0c\u4f60\u53ef\u4ee5\u5411\u6838\u5fc3\u5f00\u53d1\u8005\u63d0\u95ee\u95ee\u9898\uff0cSanic \u7684\u5b98\u65b9\u53d1\u5e03\u7ecf\u7406\u4e5f\u975e\u5e38\u4e50\u610f\u56de\u7b54\u5404\u79cd\u95ee\u9898\u3002\u4f60\u4e5f\u53ef\u4ee5\u548c\u5fd7\u540c\u9053\u5408\u7684\u4f7f\u7528\u8005\u5206\u4eab\u81ea\u5df1\u7684\u4f7f\u7528\u7ecf\u9a8c\u3002\u8fd9\u662f\u4e00\u4e2a\u5b8c\u5168\u5f00\u653e\u7684\u73af\u5883\u2026.<\/p>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">Sanic \u76ee\u524d\u5e38\u7528\u7684\u6709 \u8bba\u575b\u3001Discord\u3001github issues\u3001twitter\u3001Stackoverflow<\/p>\n<figure style=\"font-size: inherit; color: inherit; line-height: inherit;\"><img decoding=\"async\" style=\"font-size: inherit; color: inherit; line-height: inherit; display: block; margin-right: auto; margin-left: auto; border-radius: 5px; border: 1px solid gray;\" title=\"Python \u91cc\u6700\u5f3a\u7684Web\u6846\u67b6\uff0c\u65e9\u5c31\u4e0d\u662fDjango\u548cFlask\u4e86\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2021\/05\/9-1620490811-1.png\" alt=\"Python \u91cc\u6700\u5f3a\u7684Web\u6846\u67b6\uff0c\u65e9\u5c31\u4e0d\u662fDjango\u548cFlask\u4e86\" \/><\/figure>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u5927\u5bb6\u53ef\u4ee5\u5728\u4ee5\u4e0a\u7684\u65b9\u5f0f\u4e2d\u5173\u6ce8 Sanic \u7684\u53d1\u5c55\u4ee5\u53ca\u5bfb\u6c42\u793e\u533a\u5e2e\u52a9\u3002<\/p>\n<figure style=\"font-size: inherit; color: inherit; line-height: inherit;\"><img decoding=\"async\" style=\"font-size: inherit; color: inherit; line-height: inherit; display: block; margin-right: auto; margin-left: auto; border-radius: 5px; border: 1px solid gray;\" title=\"Python \u91cc\u6700\u5f3a\u7684Web\u6846\u67b6\uff0c\u65e9\u5c31\u4e0d\u662fDjango\u548cFlask\u4e86\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2021\/05\/2-1620490811-1.png\" alt=\"Python \u91cc\u6700\u5f3a\u7684Web\u6846\u67b6\uff0c\u65e9\u5c31\u4e0d\u662fDjango\u548cFlask\u4e86\" \/><\/figure>\n<p style=\"color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em; font-size: 15px; text-align: left;\">\u4f60\u8fd8\u5728\u7b49\u4ec0\u4e48\uff1f\u8fd8\u4e0d\u8d76\u7d27\u53bb\u8bd5\u4e00\u4e0b\uff1f\u6700\u540e\uff0c\u4ee5 Sanic \u7684\u613f\u666f\u7ed3\u5c3e\uff1aBuild Faster\uff0c Run Faster !<\/p>\n<figure style=\"font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; white-space: normal; background-color: #ffffff; text-align: center;\"><span style=\"text-align: justify;\">&#8212; EOF &#8212;<\/span><\/figure>\n<p style=\"font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; white-space: normal; background-color: #ffffff;\">\u00a0<\/p>\n<\/section>\n<\/div>\n\n\n<p>\u8f6c\u81ea\uff1a<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6765\u81ea\uff1a\u6398\u91d1\uff0c\u4f5c\u8005\uff1aConnorZhang \u94fe\u63a5\uff1ahttps:\/\/juejin.cn\/post\/69445986 &hellip; <a href=\"http:\/\/www.zhushiyao.com\/?p=67340\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cPython \u91cc\u6700\u5f3a\u7684Web\u6846\u67b6\uff0c\u65e9\u5c31\u4e0d\u662fDjango\u548cFlask\u4e86\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[8],"_links":{"self":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/67340"}],"collection":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=67340"}],"version-history":[{"count":2,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/67340\/revisions"}],"predecessor-version":[{"id":67353,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/67340\/revisions\/67353"}],"wp:attachment":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=67340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=67340"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=67340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}