{"id":286,"date":"2022-05-13T08:14:16","date_gmt":"2022-05-13T08:14:16","guid":{"rendered":"http:\/\/fanaticboy.com\/?p=286"},"modified":"2022-05-13T08:14:17","modified_gmt":"2022-05-13T08:14:17","slug":"python%e4%b9%8bflask%e6%a1%86%e6%9e%b6%ef%bc%88%e4%ba%8c%ef%bc%89","status":"publish","type":"post","link":"https:\/\/fanaticboy.com\/?p=286","title":{"rendered":"python\u4e4bflask\u6846\u67b6\uff08\u4e8c\uff09"},"content":{"rendered":"\n<p>\u54b1\u4eec\u4e0a\u7bc7\u6587\u7ae0\u5462\u5df2\u7ecf\u7ed9\u5927\u5bb6\u793a\u8303\u4e86\u4e00\u4e2a\u5f88\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u5927\u5bb6\u53ef\u80fd\u770b\u7684\u5f88\u61f5\uff0c\u4e0d\u77e5\u9053\u5176\u4e2d\u7684\u539f\u7406\u3002\u6216\u8bb8\u7167\u732b\u753b\u864e\u80fd\u4e0b\u6765\uff0c\u4f46\u5177\u4f53\u600e\u4e48\u8fd0\u884c\u8fd8\u4e0d\u662f\u5f88\u6e05\u695a\uff0c\u90a3\u8fd9\u7bc7\u6587\u6b63\u7ed9\u5927\u5bb6 \u89e3\u91ca\u4e00\u4e0b\u5176\u4e2d\u7684\u539f\u7406\u5e2e\u52a9\u5927\u5bb6\u7406\u89e3\u4e00\u4e0b\uff0c\u4e5f\u589e\u6dfb\u4e00\u4e9b\u65b0\u7684\u5185\u5bb9\u3002\u5148\u770b\u770b\u4e0a\u6b21\u54b1\u4eec\u5199\u7684\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\r\nfrom flask import Flask\n\r\n# \u5b9e\u4f8b\u5316Flask\uff0c\u53c2\u6570\u662f\u672c\u6587\u4ef6\r\napp = Flask(__name__)\r\n\r\n\r\n# \u88c5\u9970\u5668\uff0c\u50cf\u4e00\u9876\u88c5\u9970\u7684\u5e3d\u5b50\uff0c\u6307\u5f15\u8c03\u7528\u51fd\u6570\uff0c\u5177\u4f53\u8fc7\u7a0b\u53ef\u4ee5\u770b\u6e90\u51fd\u6570\r\n@app.route(\"\/\")\r\ndef hello():\r\n    return \"hello world\"\r\n\r\n\r\nif __name__ == '__main__':\r\n    # \u8fd0\u884c\u670d\u52a1\u5668\r\n    app.run(debug=True)<\/code><\/pre>\n\n\n\n<p>\u5177\u4f53\u89e3\u91ca\u8bf4\u660e\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>1\u3001\u9996\u5148\u6211\u4eec\u5bfc\u5165\u4e86\u00a0<a href=\"https:\/\/flask.net.cn\/api.html#flask.Flask\"><code>Flask<\/code><\/a>\u00a0\u7c7b\u3002 \u8be5\u7c7b\u7684\u5b9e\u4f8b\u5c06\u4f1a\u6210\u4e3a\u6211\u4eec\u7684 WSGI \u5e94\u7528\u3002\u5177\u4f53\u5173\u4e8eWSGI\u7684\u4ecb\u7ecd\u5927\u5bb6\u53ef\u4ee5\u770b\u4e00\u4e0b\u8fd9\u4e2a\u7f51\u5740\uff1a<a href=\"https:\/\/baike.baidu.com\/item\/wsgi\/3381529?fr=aladdin\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/baike.baidu.com\/item\/wsgi\/3381529?fr=aladdin<\/a><\/p>\n\n\n\n<p>2\u3001\u63a5\u7740\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u8be5\u7c7b\u7684\u5b9e\u4f8b\u3002\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u5e94\u7528\u6a21\u5757\u6216\u8005\u5305\u7684\u540d\u79f0\u3002\u5982\u679c\u4f60\u4f7f\u7528 \u4e00\u4e2a\u5355\u4e00\u6a21\u5757\uff08\u5c31\u50cf\u672c\u4f8b\uff09\uff0c\u90a3\u4e48\u5e94\u5f53\u4f7f\u7528\u00a0<code>__name__<\/code>\u00a0\uff0c\u56e0\u4e3a\u540d\u79f0\u4f1a\u6839\u636e\u8fd9\u4e2a \u6a21\u5757\u662f\u6309\u5e94\u7528\u65b9\u5f0f\u4f7f\u7528\u8fd8\u662f\u4f5c\u4e3a\u4e00\u4e2a\u6a21\u5757\u5bfc\u5165\u800c\u53d1\u751f\u53d8\u5316\uff08\u53ef\u80fd\u662f \u2018__main__\u2019 \uff0c \u4e5f\u53ef\u80fd\u662f\u5b9e\u9645\u5bfc\u5165\u7684\u540d\u79f0\uff09\u3002\u8fd9\u4e2a\u53c2\u6570\u662f\u5fc5\u9700\u7684\uff0c\u8fd9\u6837 Flask \u624d\u80fd\u77e5\u9053\u5728\u54ea\u91cc\u53ef\u4ee5 \u627e\u5230\u6a21\u677f\u548c\u9759\u6001\u6587\u4ef6\u7b49\u4e1c\u897f\u3002<\/p>\n\n\n\n<p>3\u3001\u7136\u540e\u6211\u4eec\u4f7f\u7528\u00a0<a href=\"https:\/\/flask.net.cn\/api.html#flask.Flask.route\"><code>route()<\/code><\/a>\u00a0\u88c5\u9970\u5668\u6765\u544a\u8bc9 Flask \u89e6\u53d1\u51fd\u6570\u7684 URL \u3002<\/p>\n\n\n\n<p>4\u3001\u51fd\u6570\u540d\u79f0\u88ab\u7528\u4e8e\u751f\u6210\u76f8\u5173\u8054\u7684 URL \u3002\u51fd\u6570\u6700\u540e\u8fd4\u56de\u9700\u8981\u5728\u7528\u6237\u6d4f\u89c8\u5668\u4e2d\u663e\u793a\u7684\u4fe1\u606f\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u90a3\u4e48\u5177\u4f53\u8ba9\u6211\u4eec\u770b\u5230\u7f51\u9875\u4e0a\u663e\u793a\u7684\u5185\u5bb9\u662f\u8def\u7531\u51fd\u6570\uff0c\u8fd9\u91cc\u8be6\u7ec6\u8bf4\u660e\u4e00\u4e0b\u8def\u7531<\/p>\n\n\n\n<p>\u73b0\u4ee3 web \u5e94\u7528\u90fd\u4f7f\u7528\u6709\u610f\u4e49\u7684 URL \uff0c\u8fd9\u6837\u6709\u52a9\u4e8e\u7528\u6237\u8bb0\u5fc6\uff0c\u7f51\u9875\u4f1a\u66f4\u5f97\u5230\u7528\u6237\u7684\u9752\u7750\uff0c \u63d0\u9ad8\u56de\u5934\u7387\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528\u00a0<a href=\"https:\/\/flask.net.cn\/api.html#flask.Flask.route\"><code>route()<\/code><\/a>\u00a0\u88c5\u9970\u5668\u6765\u628a\u51fd\u6570\u7ed1\u5b9a\u5230 URL\uff0c\u4f60\u53ef\u4ee5\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u57fa\u7840\u4e0a\u6dfb\u52a0\u8fd9\u6837\u4e00\u6bb5\u7c7b\u4f3c\u7684\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@app.route('\/hello')\r\ndef welcome():\r\n    return 'welcome! thank you!'<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u8fd0\u884c\uff0c\u5728\u6d4f\u89c8\u5668\u8f93\u5165\uff1a<a rel=\"noreferrer noopener\" href=\"http:\/\/127.0.0.1:5000\/hello\" target=\"_blank\">http:\/\/127.0.0.1:5000\/hello<\/a>\uff0c\u4f60\u4f1a\u53d1\u73b0\u53d1\u73b0\u51fa\u73b0\u4e86\u4ee5\u4e0b\u5185\u5bb9\u3002\u76f8\u4fe1\u5927\u5bb6\u5bf9URL\u548c\u8def\u7531\u5df2\u7ecf\u57fa\u672c\u6e05\u695a\u4e86\u5427\uff0c<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"450\" height=\"30\" src=\"http:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-1.png\" alt=\"\" class=\"wp-image-288\" srcset=\"https:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-1.png 450w, https:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-1-300x20.png 300w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"266\" height=\"82\" src=\"http:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-2.png\" alt=\"\" class=\"wp-image-289\"\/><\/figure>\n\n\n\n<p>\u5f53\u7136\u8fd9\u4e9b\u90fd\u662f\u4e00\u4e9b\u9759\u6001\u7684URL\u90e8\u5206\uff0c\u5bf9\u4e8e\u4e00\u4e9b\u52a8\u6001\u53d8\u5316\u7684URL\u600e\u4e48\u64cd\u4f5c\u5462\uff0c\u63a5\u4e0b\u6765\u4ecb\u7ecd\u4e00\u79cd\u53d8\u91cf\u89c4\u5219\uff1a\u901a\u8fc7\u628a URL \u7684\u4e00\u90e8\u5206\u6807\u8bb0\u4e3a\u00a0<code>&lt;variable_name><\/code>\u00a0\u5c31\u53ef\u4ee5\u5728 URL \u4e2d\u6dfb\u52a0\u53d8\u91cf\u3002\u6807\u8bb0\u7684 \u90e8\u5206\u4f1a\u4f5c\u4e3a\u5173\u952e\u5b57\u53c2\u6570\u4f20\u9012\u7ed9\u51fd\u6570\u3002\u901a\u8fc7\u4f7f\u7528\u00a0<code>&lt;converter:variable_name><\/code>\u00a0\uff0c\u53ef\u4ee5 \u9009\u62e9\u6027\u7684\u52a0\u4e0a\u4e00\u4e2a\u8f6c\u6362\u5668\uff0c\u4e3a\u53d8\u91cf\u6307\u5b9a\u89c4\u5219\u3002\u8bf7\u770b\u4e0b\u9762\u7684\u4f8b\u5b50:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@app.route('\/user\/&lt;username>')\r\ndef show_user_profile(username):\r\r\n    return 'User %s' % escape(username)\r\n\r\n@app.route('\/post\/&lt;int:post_id>')\r\ndef show_post(post_id):\r\n    return 'Post %d' % post_id\r\n\r\n@app.route('\/path\/&lt;path:subpath>')\r\ndef show_subpath(subpath):\r\n    return 'Subpath %s' % escape(subpath)<\/code><\/pre>\n\n\n\n<p>\u8f6c\u6362\u5668\u7c7b\u578b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><code>string<\/code><\/td><td>\uff08\u7f3a\u7701\u503c\uff09 \u63a5\u53d7\u4efb\u4f55\u4e0d\u5305\u542b\u659c\u6760\u7684\u6587\u672c<\/td><\/tr><tr><td><code>int<\/code><\/td><td>\u63a5\u53d7\u6b63\u6574\u6570<\/td><\/tr><tr><td><code>float<\/code><\/td><td>\u63a5\u53d7\u6b63\u6d6e\u70b9\u6570<\/td><\/tr><tr><td><code>path<\/code><\/td><td>\u7c7b\u4f3c&nbsp;<code>string<\/code>&nbsp;\uff0c\u4f46\u53ef\u4ee5\u5305\u542b\u659c\u6760<\/td><\/tr><tr><td><code>uuid<\/code><\/td><td>\u63a5\u53d7 UUID \u5b57\u7b26\u4e32<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u5c06\u4e0a\u9762\u7684\u4f8b\u5b50\u6dfb\u52a0\u5230\u54b1\u4eec\u5199\u7684\u4ee3\u7801\u4e2d\uff0c\u7136\u540e\u5728\u9876\u90e8\u52a0\u5165\u5bfc\u5165\u4e00\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from html import escape<\/pre>\n\n\n\n<p>\u7136\u540e\u8fd0\u884c\uff0c\u5728\u6d4f\u89c8\u5668\u4e2d\u8f93\u5165\uff1a<a rel=\"noreferrer noopener\" href=\"http:\/\/127.0.0.1:5000\/user\/xiaoli\" target=\"_blank\">http:\/\/127.0.0.1:5000\/user\/xiaoli<\/a>\uff0c\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u5185\u5bb9<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"458\" height=\"37\" src=\"http:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-3.png\" alt=\"\" class=\"wp-image-290\" srcset=\"https:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-3.png 458w, https:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-3-300x24.png 300w\" sizes=\"auto, (max-width: 458px) 100vw, 458px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"251\" height=\"100\" src=\"http:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-4.png\" alt=\"\" class=\"wp-image-291\"\/><\/figure>\n\n\n\n<p>\u5728\u6d4f\u89c8\u5668\u4e2d\u8f93\u5165\uff1a<a rel=\"noreferrer noopener\" href=\"http:\/\/127.0.0.1:5000\/post\/1\" target=\"_blank\">http:\/\/127.0.0.1:5000\/post\/1<\/a>\uff0c\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u5185\u5bb9<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"434\" height=\"58\" src=\"http:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-6.png\" alt=\"\" class=\"wp-image-293\" srcset=\"https:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-6.png 434w, https:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-6-300x40.png 300w\" sizes=\"auto, (max-width: 434px) 100vw, 434px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"226\" height=\"97\" src=\"http:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-7.png\" alt=\"\" class=\"wp-image-294\"\/><\/figure>\n\n\n\n<p>\u90a3\u4e48\u5982\u679c\u8f93\u5165\uff1a<a rel=\"noreferrer noopener\" href=\"http:\/\/127.0.0.1:5000\/post\/xiaoli\" target=\"_blank\">http:\/\/127.0.0.1:5000\/post\/xiaoli<\/a>\u4f1a\u600e\u4e48\u6837\u5462\uff0c\u53ef\u4ee5\u8bd5\u4e00\u4e0b\uff0c\u4f1a\u51fa\u73b0not found\uff0c\u8fd9\u662f\u56e0\u4e3a\u63a5\u53d7\u7684\u7c7b\u578b\u4e3aint\u7c7b\u578b\uff0c\u6240\u4ee5\u5176\u4ed6\u7c7b\u578b\u4e0d\u80fd\u8bbf\u95ee<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"434\" height=\"51\" src=\"http:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-8.png\" alt=\"\" class=\"wp-image-295\" srcset=\"https:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-8.png 434w, https:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-8-300x35.png 300w\" sizes=\"auto, (max-width: 434px) 100vw, 434px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"303\" height=\"87\" src=\"http:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-9.png\" alt=\"\" class=\"wp-image-296\" srcset=\"https:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-9.png 303w, https:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-9-300x86.png 300w\" sizes=\"auto, (max-width: 303px) 100vw, 303px\" \/><\/figure>\n\n\n\n<p>\u63a5\u4e0b\u6765\u5728\u6d4f\u89c8\u5668\u4e2d\u8f93\u5165\uff1a<a rel=\"noreferrer noopener\" href=\"http:\/\/127.0.0.1:5000\/path\/a\/a\" target=\"_blank\">http:\/\/127.0.0.1:5000\/path\/a\/a<\/a>\uff0c\u5c06\u4f1a\u770b\u5230\u4ee5\u4e0b\u5185\u5bb9,path\u540e\u9762\u53ef\u4ee5\u52a0\u5e26\u659c\u6760\u7684\u5185\u5bb9<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"431\" height=\"36\" src=\"http:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-10.png\" alt=\"\" class=\"wp-image-297\" srcset=\"https:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-10.png 431w, https:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-10-300x25.png 300w\" sizes=\"auto, (max-width: 431px) 100vw, 431px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"279\" height=\"72\" src=\"http:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-11.png\" alt=\"\" class=\"wp-image-298\"\/><\/figure>\n\n\n\n<p>\u63a5\u4e0b\u6765\u8bf4\u4e00\u4e0b\u4e00\u6761\u89c4\u5219\uff1a\u552f\u4e00\u7684 URL \/ \u91cd\u5b9a\u5411\u884c\u4e3a\uff0c\u5148\u770b\u4e0b\u9762\u7684\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@app.route('\/zhou\/')\r\ndef projects():\r\n    return 'Mr zhou'\r\n\r\n@app.route('\/hong')\r\ndef about():\r\n    return 'Mr hong'<\/code><\/pre>\n\n\n\n<p><code>zhou<\/code>\u7684 URL \u662f\u4e2d\u89c4\u4e2d\u77e9\u7684\uff0c\u5c3e\u90e8\u6709\u4e00\u4e2a\u659c\u6760\uff0c\u770b\u8d77\u6765\u5c31\u5982\u540c\u4e00\u4e2a\u6587\u4ef6\u5939\u3002 \u8bbf\u95ee\u4e00\u4e2a\u6ca1\u6709\u659c\u6760\u7ed3\u5c3e\u7684 URL \u65f6 Flask \u4f1a\u81ea\u52a8\u8fdb\u884c\u91cd\u5b9a\u5411\uff0c\u5e2e\u4f60\u5728\u5c3e\u90e8\u52a0\u4e0a\u4e00\u4e2a\u659c\u6760\u3002<\/p>\n\n\n\n<p><code>hong<\/code>\u00a0\u7684 URL \u6ca1\u6709\u5c3e\u90e8\u659c\u6760\uff0c\u56e0\u6b64\u5176\u884c\u4e3a\u8868\u73b0\u4e0e\u4e00\u4e2a\u6587\u4ef6\u7c7b\u4f3c\u3002\u5982\u679c\u8bbf\u95ee\u8fd9\u4e2a URL \u65f6\u6dfb\u52a0\u4e86\u5c3e\u90e8\u659c\u6760\u5c31\u4f1a\u5f97\u5230\u4e00\u4e2a 404 \u9519\u8bef\u3002\u8fd9\u6837\u53ef\u4ee5\u4fdd\u6301 URL \u552f\u4e00\uff0c\u5e76\u5e2e\u52a9 \u641c\u7d22\u5f15\u64ce\u907f\u514d\u91cd\u590d\u7d22\u5f15\u540c\u4e00\u9875\u9762\u3002<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u8bf4\u4e00\u4e0bURL\u7684\u6784\u5efa\uff0c\u4f7f\u7528url_for()\u00a0\u51fd\u6570\uff0curl_for()\u51fd\u6570\u63a5\u53d7\u51fd\u6570\u7684\u540d\u79f0\u4f5c\u4e3a\u7b2c\u4e00\u4e2a\u53c2\u6570\uff0c\u4ee5\u53ca\u4e00\u4e2a\u6216\u591a\u4e2a\u5173\u952e\u5b57\u53c2\u6570\uff0c\u6bcf\u4e2a\u53c2\u6570\u5bf9\u5e94\u4e8eURL\u7684\u53d8\u91cf\u90e8\u5206\u3002\u4e0b\u9762\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u9996\u5148\u5bfc\u5165\u4e00\u4e0burl_for\u548credirect<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from flask import Flask, redirect, url_for<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u5728\u4e4b\u524d\u7684\u57fa\u7840\u4e0a\u589e\u52a0\u5982\u4e0b\u4ee3\u7801,\u7136\u540e\u542f\u52a8<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@app.route('\/xiao')\r\ndef hello_xiao():\r\n    return 'Hello xiao'\r\n\r\n\r\n@app.route('\/li\/&lt;li>')\r\ndef hello_li(li):\r\n    return 'Hello %s as li' % li\r\n\r\n\r\n@app.route('\/cus\/&lt;name>')\r\ndef hello_user(name):\r\n    if name == 'xiao':\r\n        return redirect(url_for('hello_xiao'))\r\n    else:\r\n        return redirect(url_for('hello_li', li=name))<\/code><\/pre>\n\n\n\n<p>\u542f\u52a8\u5b8c\u4e4b\u540e\uff0c\u5728\u6d4f\u89c8\u5668\u4e0a\u9762\u8f93\u5165\u4ee5\u4e0b\u4e24URL\u770b\u4e00\u4e0b\u6548\u679c<\/p>\n\n\n\n<p>\u5148\u8f93\u5165\u4e00\u4e0b:<a href=\"http:\/\/127.0.0.1:5000\/cus\/xiao\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/127.0.0.1:5000\/cus\/xiao<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"434\" height=\"57\" src=\"http:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-12.png\" alt=\"\" class=\"wp-image-299\" srcset=\"https:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-12.png 434w, https:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-12-300x39.png 300w\" sizes=\"auto, (max-width: 434px) 100vw, 434px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"239\" height=\"122\" src=\"http:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-14.png\" alt=\"\" class=\"wp-image-301\"\/><\/figure>\n\n\n\n<p>\u518d\u8f93\u5165\u4e00\u4e0b:<a href=\"http:\/\/127.0.0.1:5000\/cus\/xia\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/127.0.0.1:5000\/cus\/xia<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"235\" height=\"129\" src=\"http:\/\/fanaticboy.com\/wp-content\/uploads\/2022\/05\/image-13.png\" alt=\"\" class=\"wp-image-300\"\/><\/figure>\n\n\n\n<p>\u540c\u65f6\u54b1\u4eec\u4e5f\u4f1a\u53d1\u73b0\u5730\u5740\u680f\u4e2dURL\u8fdb\u884c\u4e86\u91cd\u5b9a\u5411\uff0c\u8fd9\u4e2a\u5c31\u662furl_for()\u00a0\u51fd\u6570\u7684\u4f5c\u7528<\/p>\n\n\n\n<p>\u597d\u4e86\uff0c\u672c\u7bc7\u6587\u7ae0\u5c31\u5230\u8fd9\u91cc\u4e86\uff0c\u66f4\u591a\u5185\u5bb9\u7b49\u5f85\u4e0b\u4e00\u7bc7\u7684\u66f4\u65b0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u54b1\u4eec\u4e0a\u7bc7\u6587\u7ae0\u5462\u5df2\u7ecf\u7ed9\u5927\u5bb6\u793a\u8303\u4e86\u4e00\u4e2a\u5f88\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u5927\u5bb6\u53ef\u80fd\u770b\u7684\u5f88\u61f5\uff0c\u4e0d\u77e5\u9053\u5176\u4e2d\u7684\u539f\u7406\u3002\u6216\u8bb8\u7167\u732b\u753b\u864e\u80fd\u4e0b\u6765\uff0c\u4f46\u5177\u4f53 &#8230; <a title=\"python\u4e4bflask\u6846\u67b6\uff08\u4e8c\uff09\" class=\"read-more\" href=\"https:\/\/fanaticboy.com\/?p=286\" aria-label=\"\u9605\u8bfb python\u4e4bflask\u6846\u67b6\uff08\u4e8c\uff09\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,15],"tags":[],"class_list":["post-286","post","type-post","status-publish","format-standard","hentry","category-flask","category-python"],"_links":{"self":[{"href":"https:\/\/fanaticboy.com\/index.php?rest_route=\/wp\/v2\/posts\/286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fanaticboy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fanaticboy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fanaticboy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fanaticboy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286"}],"version-history":[{"count":1,"href":"https:\/\/fanaticboy.com\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions"}],"predecessor-version":[{"id":302,"href":"https:\/\/fanaticboy.com\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions\/302"}],"wp:attachment":[{"href":"https:\/\/fanaticboy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fanaticboy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fanaticboy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}