{"id":12890,"date":"2025-04-18T20:02:40","date_gmt":"2025-04-18T12:02:40","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/12890.html"},"modified":"2025-04-18T20:02:40","modified_gmt":"2025-04-18T12:02:40","slug":"python%e7%b3%bb%e5%88%97-flask%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e5%a6%82%e4%bd%95%e5%bf%ab%e9%80%9f%e5%88%9b%e5%bb%ba%e8%87%aa%e5%b7%b1%e7%9a%84api%e5%b9%b6%e9%83%a8%e7%bd%b2%e5%88%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/12890.html","title":{"rendered":"python\u7cfb\u5217 Flask\u65b0\u624b\u6559\u7a0b\uff1a\u5982\u4f55\u5feb\u901f\u521b\u5efa\u81ea\u5df1\u7684api\u5e76\u90e8\u7f72\u5230\u670d\u52a1\u5668"},"content":{"rendered":"<hr>\n<p>\u4e2a\u4eba\u7b80\u4ecb<\/p>\n<p>\ud83d\udc68\ud83c\udffb\u200d\ud83d\udcbb\u4e2a\u4eba\u4e3b\u9875\uff1a\u4e5d\u9eceaj<\/p>\n<p>\ud83c\udfc3\ud83c\udffb\u200d\u2642\ufe0f\u5e78\u798f\u6e90\u81ea\u594b\u6597,\u5e73\u51e1\u9020\u5c31\u4e0d\u51e1<\/p>\n<p>\ud83c\udf1f\u5982\u679c\u6587\u7ae0\u5bf9\u4f60\u6709\u7528\uff0c\u9ebb\u70e6\u5173\u6ce8\u70b9\u8d5e\u6536\u85cf\u8d70\u4e00\u6ce2\uff0c\u611f\u8c22\u652f\u6301\uff01<\/p>\n<p>\ud83c\udf31\u6b22\u8fce\u8ba2\u9605\u6211\u7684\u4e13\u680f\uff1aautojs python \ud83c\udf1f QQ\u7fa4\uff1a698307198<\/p>\n<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\u524d\u8a00<\/li>\n<li>Flask API \u65b0\u624b\u6559\u7a0b\uff1a\u5982\u4f55\u5feb\u901f\u521b\u5efa\u81ea\u5df1\u7684 API<\/li>\n<li>\n<ul>\n<li>\u7b2c\u4e00\u6b65\uff1a\u5b89\u88c5 Flask<\/li>\n<li>\u7b2c\u4e8c\u6b65\uff1a\u521b\u5efa Flask \u9879\u76ee<\/li>\n<li>\u7b2c\u4e09\u6b65\uff1a\u7f16\u5199\u7b2c\u4e00\u4e2a Flask \u5e94\u7528<\/li>\n<li>\n<ul>\n<li>1. \u5bfc\u5165 Flask \u5e76\u521d\u59cb\u5316\u5e94\u7528<\/li>\n<li>2. \u521b\u5efa POST \u63a5\u53e3 `\/api_v1\/user\/vipState`<\/li>\n<li>3. \u521b\u5efa GET \u63a5\u53e3 `\/api_v1\/user\/getUserId`<\/li>\n<li>4. \u521b\u5efa GET \u63a5\u53e3 `\/files\/yunjing.json`<\/li>\n<li>6. \u542f\u52a8 Flask \u5e94\u7528<\/li>\n<\/ul>\n<\/li>\n<li>\u7b2c\u56db\u6b65\uff1a\u8fd0\u884c Flask \u5e94\u7528<\/li>\n<li>\u7b2c\u4e94\u6b65\uff1a\u90e8\u7f72\u5230\u670d\u52a1\u5668<\/li>\n<li>\u7ed3\u8bba<\/li>\n<li>4.<\/li>\n<\/ul>\n<\/li>\n<li>\u603b\u7ed3<\/li>\n<li>\u52a0\u5165\u4ea4\u6d41\u7fa4<\/li>\n<\/ul>\n<hr>\n<h2>\u524d\u8a00<\/h2>\n<p>\u5927\u6982\u5185\u5bb9\uff1a`<\/p>\n<p>\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014<\/p>\n<p>`\u4ee5\u4e0b\u662f\u672c\u7bc7\u6587\u7ae0\u6b63\u6587\u5185\u5bb9\uff0c<\/p>\n<h2>Flask API \u65b0\u624b\u6559\u7a0b\uff1a\u5982\u4f55\u5feb\u901f\u521b\u5efa\u81ea\u5df1\u7684 API<\/h2>\n<p>Flask \u662f\u4e00\u4e2a\u7b80\u5355\u800c\u5f3a\u5927\u7684 Python \u5fae\u6846\u67b6\uff0c\u9002\u5408\u7528\u6765\u5feb\u901f\u521b\u5efa API\u3002\u672c\u6587\u5c06\u624b\u628a\u624b\u6559\u4f60\u5982\u4f55\u4f7f\u7528 Flask \u7f16\u5199\u548c\u90e8\u7f72\u81ea\u5df1\u7684 API\uff0c\u9002\u5408\u65b0\u624b\u3002<\/p>\n<h3>\u7b2c\u4e00\u6b65\uff1a\u5b89\u88c5 Flask<\/h3>\n<p>\u5728\u5f00\u59cb\u7f16\u5199\u4ee3\u7801\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u5148\u5b89\u88c5 Flask\u3002\u5982\u679c\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86 Python\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5 Flask\uff1a<\/p>\n<p>pip <span class=\"token function\">install<\/span> Flask<\/p>\n<p>\u786e\u4fdd\u5b89\u88c5\u6210\u529f\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7 flask &#8211;version \u6765\u9a8c\u8bc1\u662f\u5426\u5b89\u88c5\u6b63\u786e\u3002<\/p>\n<h3>\u7b2c\u4e8c\u6b65\uff1a\u521b\u5efa Flask \u9879\u76ee<\/h3>\n<p>\u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u9879\u76ee\u76ee\u5f55\uff0c\u5e76\u5728\u8be5\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a Python \u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u6587\u4ef6\u540d\u4e3a app.py\u3002<\/p>\n<p><span class=\"token function\">mkdir<\/span> flask-api<br \/>\n<span class=\"token builtin class-name\">cd<\/span> flask-api<br \/>\n<span class=\"token function\">touch<\/span> app.py<\/p>\n<p>\u6253\u5f00 app.py \u6587\u4ef6\uff0c\u5f00\u59cb\u7f16\u5199\u4f60\u7684\u7b2c\u4e00\u4e2a Flask \u5e94\u7528\u3002<\/p>\n<h3>\u7b2c\u4e09\u6b65\uff1a\u7f16\u5199\u7b2c\u4e00\u4e2a Flask \u5e94\u7528<\/h3>\n<p>\u6211\u4eec\u5c06\u5728\u8fd9\u4e2a\u5e94\u7528\u4e2d\u521b\u5efa\u51e0\u4e2a API \u63a5\u53e3\uff0c\u8fd9\u4e9b\u63a5\u53e3\u5c06\u8fd4\u56de JSON \u6570\u636e\u3002<\/p>\n<h4>1. \u5bfc\u5165 Flask \u5e76\u521d\u59cb\u5316\u5e94\u7528<\/h4>\n<p>\u9996\u5148\uff0c\u5bfc\u5165 Flask \u5e76\u521d\u59cb\u5316\u5e94\u7528\uff1a<\/p>\n<p><span class=\"token keyword\">from<\/span> flask <span class=\"token keyword\">import<\/span> Flask<span class=\"token punctuation\">,<\/span> jsonify<\/p>\n<p>app <span class=\"token operator\">=<\/span> Flask<span class=\"token punctuation\">(<\/span>__name__<span class=\"token punctuation\">)<\/span><\/p>\n<p>Flask \u662f\u6838\u5fc3\u7c7b\uff0c\u7528\u4e8e\u521b\u5efa\u5e94\u7528\u5b9e\u4f8b\uff0cjsonify \u662f\u4e00\u4e2a\u5e2e\u52a9\u51fd\u6570\uff0c\u53ef\u4ee5\u5c06 Python \u5b57\u5178\u81ea\u52a8\u8f6c\u6362\u4e3a JSON \u683c\u5f0f\u3002<\/p>\n<h4>2. \u521b\u5efa POST \u63a5\u53e3 \/api_v1\/user\/vipState<\/h4>\n<p>\u8fd9\u662f\u6211\u4eec\u7684\u7b2c\u4e00\u4e2a API \u63a5\u53e3\uff0c\u5b83\u5c06\u5904\u7406 POST \u8bf7\u6c42\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a JSON \u54cd\u5e94\u3002<\/p>\n<p><span class=\"token decorator annotation punctuation\">@app<span class=\"token punctuation\">.<\/span>route<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">\\&#8217;\/api_v1\/user\/vipState\\&#8217;<\/span><span class=\"token punctuation\">,<\/span> methods<span class=\"token operator\">=<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">\\&#8217;POST\\&#8217;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">def<\/span> <span class=\"token function\">vip_state<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2k\u6b21\uff0c\u70b9\u8d5e24\u6b21\uff0c\u6536\u85cf37\u6b21\u3002Flask API \u65b0\u624b\u6559\u7a0b\uff1a\u5982\u4f55\u5feb\u901f\u521b\u5efa\u81ea\u5df1\u7684 API_python\u642d\u5efaapi\u670d\u52a1\u5668<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[153,81,43,742],"topic":[],"class_list":["post-12890","post","type-post","status-publish","format-standard","hentry","category-server","tag-flask","tag-python","tag-43","tag-742"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>python\u7cfb\u5217 Flask\u65b0\u624b\u6559\u7a0b\uff1a\u5982\u4f55\u5feb\u901f\u521b\u5efa\u81ea\u5df1\u7684api\u5e76\u90e8\u7f72\u5230\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/12890.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"python\u7cfb\u5217 Flask\u65b0\u624b\u6559\u7a0b\uff1a\u5982\u4f55\u5feb\u901f\u521b\u5efa\u81ea\u5df1\u7684api\u5e76\u90e8\u7f72\u5230\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2k\u6b21\uff0c\u70b9\u8d5e24\u6b21\uff0c\u6536\u85cf37\u6b21\u3002Flask API \u65b0\u624b\u6559\u7a0b\uff1a\u5982\u4f55\u5feb\u901f\u521b\u5efa\u81ea\u5df1\u7684 API_python\u642d\u5efaapi\u670d\u52a1\u5668\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/12890.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T12:02:40+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/12890.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/12890.html\",\"name\":\"python\u7cfb\u5217 Flask\u65b0\u624b\u6559\u7a0b\uff1a\u5982\u4f55\u5feb\u901f\u521b\u5efa\u81ea\u5df1\u7684api\u5e76\u90e8\u7f72\u5230\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T12:02:40+00:00\",\"dateModified\":\"2025-04-18T12:02:40+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/12890.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/12890.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/12890.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"python\u7cfb\u5217 Flask\u65b0\u624b\u6559\u7a0b\uff1a\u5982\u4f55\u5feb\u901f\u521b\u5efa\u81ea\u5df1\u7684api\u5e76\u90e8\u7f72\u5230\u670d\u52a1\u5668\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"python\u7cfb\u5217 Flask\u65b0\u624b\u6559\u7a0b\uff1a\u5982\u4f55\u5feb\u901f\u521b\u5efa\u81ea\u5df1\u7684api\u5e76\u90e8\u7f72\u5230\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/12890.html","og_locale":"zh_CN","og_type":"article","og_title":"python\u7cfb\u5217 Flask\u65b0\u624b\u6559\u7a0b\uff1a\u5982\u4f55\u5feb\u901f\u521b\u5efa\u81ea\u5df1\u7684api\u5e76\u90e8\u7f72\u5230\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2k\u6b21\uff0c\u70b9\u8d5e24\u6b21\uff0c\u6536\u85cf37\u6b21\u3002Flask API \u65b0\u624b\u6559\u7a0b\uff1a\u5982\u4f55\u5feb\u901f\u521b\u5efa\u81ea\u5df1\u7684 API_python\u642d\u5efaapi\u670d\u52a1\u5668","og_url":"https:\/\/www.wsisp.com\/helps\/12890.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T12:02:40+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/12890.html","url":"https:\/\/www.wsisp.com\/helps\/12890.html","name":"python\u7cfb\u5217 Flask\u65b0\u624b\u6559\u7a0b\uff1a\u5982\u4f55\u5feb\u901f\u521b\u5efa\u81ea\u5df1\u7684api\u5e76\u90e8\u7f72\u5230\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T12:02:40+00:00","dateModified":"2025-04-18T12:02:40+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/12890.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/12890.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/12890.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"python\u7cfb\u5217 Flask\u65b0\u624b\u6559\u7a0b\uff1a\u5982\u4f55\u5feb\u901f\u521b\u5efa\u81ea\u5df1\u7684api\u5e76\u90e8\u7f72\u5230\u670d\u52a1\u5668"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/12890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=12890"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/12890\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=12890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=12890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=12890"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=12890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}