{"id":372,"date":"2018-10-14T05:00:19","date_gmt":"2018-10-13T21:00:19","guid":{"rendered":"http:\/\/develop-note.com\/blog\/?p=372"},"modified":"2022-02-16T22:17:10","modified_gmt":"2022-02-16T14:17:10","slug":"2019ironman-flask-restful-day13","status":"publish","type":"post","link":"https:\/\/www.develop-note.com\/blog\/2018\/10\/14\/2019ironman-flask-restful-day13\/","title":{"rendered":"\u7b2c\u5341\u5c46\u9435\u4eba\u8cfd flask-restful DAY13-\u641e\u61c2restful"},"content":{"rendered":"<h1>\u751a\u9ebc\u662frestful<\/h1>\n<p>\u8aaa\u5230restful\u5c31\u4e0d\u80fd\u4e0d\u63d0\u90a6\u53cbkerkerj\u7684<a href=\"https:\/\/ithelp.ithome.com.tw\/users\/20091343\/ironman\/762\" rel=\"nofollow noopener\" target=\"_blank\">\u5f9e\u7121\u5230\u6709\u6253\u9020 RESTful API service \u7cfb\u5217<\/a>\u5176\u4e2d<a href=\"https:\/\/ithelp.ithome.com.tw\/articles\/10157431\" rel=\"nofollow noopener\" target=\"_blank\">[API] (1) &#8211; \u5b9a\u7fa9 1 &#8211; \u4ec0\u9ebc\u662f REST\/RESTful ?<\/a>\u5c31\u8f09\u660e\u4e86\u4ec0\u9ebc\u662frestful\uff0c\u60f3\u6df1\u5165\u4e86\u89e3\u7684\u53ef\u4ee5\u8b80\u4e00\u8b80\u9019\u7bc7\u6587\u7ae0\uff0c\u9664\u6b64\u4e4b\u5916<a href=\"https:\/\/zh.wikipedia.org\/wiki\/%E8%A1%A8%E7%8E%B0%E5%B1%82%E7%8A%B6%E6%80%81%E8%BD%AC%E6%8D%A2\" rel=\"nofollow noopener\" target=\"_blank\">\u7dad\u57fa\u767e\u79d1<\/a>\u4e5f\u8f09\u660e\u4e86\u8a31\u591a\u5167\u5bb9\uff0c\u5728\u9019\u88e1\u7b46\u8005\u5c31\u91cd\u9ede\u5f0f\u7684\u63d0\u53ca\u4e00\u4e9b\u89c0\u5ff5\u3002<!--more--><\/p>\n<h1>\u8868\u73fe\u5c64\u72c0\u614b\u8f49\u63db(rest \/ restful)<\/h1>\n<p>\u76f8\u4fe1\u8b80\u8005\u770b\u5230\u4e0a\u9762\u7684\u89e3\u91cb\u61c9\u8a72\u4e0d\u77e5\u9053\u4ed6\u5728\u8aaa\u751a\u9ebc\uff0c\u5176\u5be6rest\u4e5f\u4e0d\u662f\u751a\u9ebc\u898f\u7bc4\u6216\u662f\u898f\u5b9a\uff0c\u4ed6\u53ea\u662f\u4e00\u7a2e\u8a2d\u8a08\u63d0\u4f9b\u5168\u7403\u8cc7\u8a0a\u7db2\u7d61\u670d\u52d9\u7684\u8edf\u9ad4\u69cb\u5efa\u98a8\u683c\uff0c\u800c\u7b26\u5408\u6b64\u98a8\u683c\u7684\u7db2\u8def\u670d\u52d9\u5c31\u7a31\u70barest\u6216\u662frestful\u3002<br \/>\n\u4e0d\u904e\u8aaa\u4e86\u90a3\u9ebc\u591a\uff0c\u5230\u5e95\u662f\u751a\u9ebc\u98a8\u683c\u5462?\u57fa\u672c\u4e0a\u5c31\u662f\u7b26\u5408\u4ee5\u4e0b\u516d\u7a2e\u898f\u7bc4\u7684\u98a8\u683c\u5373\u662f\uff1a<\/p>\n<ul>\n<li>\u5ba2\u6236-\u4f3a\u670d\u5668(Client-Server) &#8211; \u7531\u5ba2\u6236\u7aef\u767c\u8d77\u7684\u9700\u6c42<\/li>\n<li>\u7121\u72c0\u614b(Stateless) &#8211; \u901a\u8a0a\u7684\u72c0\u614b\u7531\u5ba2\u6236\u7aef\u8ca0\u8cac\u7dad\u8b77<\/li>\n<li>\u5feb\u53d6(Cache) &#8211; \u56de\u61c9\u5167\u5bb9\u53ef\u4ee5\u5728\u901a\u8a0a\u93c8\u7684\u67d0\u8655\u88ab\u5feb\u53d6\uff0c\u4ee5\u6539\u5584\u7db2\u8def\u6548\u7387\u3002<\/li>\n<li>\u7d71\u4e00\u57e0(Uniform Interface)- \u6b64\u8655\u900f\u904e\u8d85\u6587\u672c\u50b3\u8f38\u5354\u5b9a(HTTP)\u4f86\u50b3\u905e\u8cc7\u8a0a<\/li>\n<li>\u5206\u5c64\u7cfb\u7d71(Layered System)- \u901a\u904e\u9650\u5236\u5143\u4ef6\u7684\u884c\u70ba\uff0c\u5c07\u67b6\u69cb\u5206\u89e3\u70ba\u82e5\u5e72\u7b49\u7d1a\u7684\u5c64\u3002<\/li>\n<\/ul>\n<h1>\u8d85\u6587\u672c\u50b3\u8f38\u5354\u5b9a(HTTP)<\/h1>\n<p>\u5728rest\u898f\u7bc4\u4e2d\u7684\u7d71\u4e00\u57e0\u898f\u7bc4\u5373\u662f\u4ee5\u8d85\u6587\u672c\u50b3\u8f38\u5354\u5b9a\u4f86\u5be6\u73fe\u9019\u898f\u7bc4\uff0c\u800c\u751a\u9ebc\u662f\u8d85\u6587\u672c\u50b3\u8f38\u5354\u5b9a\u5462\uff0c\u57fa\u672c\u4e0a\u76ee\u524d\u4f60\u6211\u4f7f\u7528\u7684\u700f\u89bd\u5668\u5c31\u662f\u9075\u5faa\u9019\u500b\u898f\u7bc4\u4f86\u50b3\u8f38\u8cc7\u8a0a\u7684\uff0c\u800crestful\u53c8\u600e\u9ebc\u8ddf\u9019\u626f\u4e0a\u908a\u5462\uff0c\u7c21\u55ae\u8b1b\u5c31\u662frestful\u5c07\u8d85\u6587\u672c\u50b3\u8f38\u5354\u5b9a\u767c\u63da\u5149\u5927\uff0c\u7576\u5ba2\u6236\u7aef\u767c\u51fa\u9700\u6c42\u4e0d\u7528\u7279\u5225\u601d\u8003\u5c31\u900f\u904e\u8acb\u6c42\u767c\u6cd5\u7684\u898f\u7bc4\u4f86\u767c\u51fa\uff0c\u800c\u4f3a\u670d\u5668\u7aef\u5c31\u4f9d\u64da\u72c0\u614b\u78bc\u7684\u898f\u7bc4\u4f86\u56de\u5fa9\u72c0\u614b\u78bc\uff0c\u5982\u6b64\u5ba2\u6236\u7aef\u8207\u4f3a\u670d\u5668\u7aef\u96d6\u7136\u6c92\u6709\u5171\u901a\u7684\u8a9e\u8a00\uff0c\u4f46\u662f\u5f7c\u6b64\u90fd\u77e5\u9053\u76f8\u4e92\u8aaa\u7684\u6771\u897f\u662f\u751a\u9ebc\u3002\u63a5\u4e0b\u4f86\u8981\u5206\u5225\u91dd\u5c0d\u8acb\u6c42\u65b9\u6cd5\u4ee5\u53ca\u72c0\u614b\u78bc\u4f86\u8aaa\u660e\u4e00\u4e0b\uff0c\u7562\u7adf\u5ba2\u6236\u7aef\u8207\u4f3a\u670d\u5668\u7aef\u90fd\u77e5\u9053\u4f46\u662f\u8b80\u8005\u4e0d\u77e5\u9053\u9019\u600e\u9ebc\u53ef\u4ee5\u5462\u3002<\/p>\n<h2>\u8acb\u6c42\u65b9\u6cd5<\/h2>\n<p>\u9019\u90e8\u5206\u8aaa\u660e\u7684\u662f\u5ba2\u6236\u7aef\u63d0\u51fa\u9700\u6c42\u6709\u4e0b\u5217\u5e7e\u7a2e\u65b9\u6cd5\uff0c\u6bcf\u7a2e\u65b9\u6cd5\u90fd\u6709\u7279\u5225\u7684\u542b\u610f\uff0c\u4ee5\u4e0b\u91dd\u5c0d\u6bcf\u4e00\u7a2e\u65b9\u6cd5\u8aaa\u660e\u5176\u5167\u5bb9<\/p>\n<h4>GET<\/h4>\n<p>\u5411\u4f3a\u670d\u5668\u63d0\u51fa<code><code>\u53d6\u5f97<\/code><\/code>\u8cc7\u8a0a\u7684\u8acb\u6c42\uff0c\u6240\u4ee5\u4f3a\u670d\u5668\u8655\u7406\u6b64\u985e\u7684\u8acb\u6c42\u4e0d\u61c9\u6709\u66f4\u6539\u8cc7\u6599\u7684\u52d5\u4f5c\u3002<\/p>\n<h4>POST<\/h4>\n<p>\u5411\u6307\u5b9a\u8cc7\u6e90\u63d0\u4ea4\u8cc7\u6599\uff0c\u8acb\u6c42\u4f3a\u670d\u5668\u9032\u884c\u8655\u7406\u66f4\u65b0\u8cc7\u6599\u7684\u65b9\u6cd5\uff0c\u82e5\u662f\u5b58\u5728\u8cc7\u6599\u6642\u5247\u6703\u518d<code><code>\u65b0\u589e<\/code><\/code>\u4e00\u7b46<\/p>\n<h4>PUT<\/h4>\n<p>\u5411\u6307\u5b9a\u8cc7\u6e90\u4f4d\u7f6e\u4e0a\u50b3\u5176\u6700\u65b0\u5167\u5bb9\uff0c\u5982\u679c\u5b58\u5728\u5c31\u6709\u8cc7\u6599\u5c31<code><code>\u66f4\u65b0<\/code><\/code>\u8cc7\u6599<\/p>\n<h4>PATCH<\/h4>\n<p>\u5411\u4f3a\u670d\u5668\u63d0\u51fa\u4fee\u6539\u5c40\u90e8\u8cc7\u6599\u7684\u8acb\u6c42\uff0c\u8207<code><code>POST<\/code>`<code>\u76f8\u6bd4\u5c31\u662f\u6703<\/code>`<code>\u65b0\u589e\u5f88\u591a\u7b46<\/code><\/code>\u8cc7\u6599<\/p>\n<h4>DELETE<\/h4>\n<p>\u5411\u4f3a\u670d\u5668\u63d0\u51fa<code><code>\u522a\u9664<\/code><\/code>\u8cc7\u6599\u7684\u8acb\u6c42<\/p>\n<h2>\u72c0\u614b\u78bc<\/h2>\n<p>\u9019\u90e8\u5206\u8aaa\u660e\u7684\u662f\u4f3a\u670d\u5668\u7aef\u56de\u5fa9\u5ba2\u6236\u7aef\u7684\u7d50\u679c\uff0c\u96d6\u7136\u53ea\u662f\u4e00\u500b\u72c0\u614b\u78bc\u4f46\u662f\u537b\u80fd\u900f\u904e\u4e00\u500b\u5e8f\u865f\u77e5\u9053\u7d50\u679c\u600e\u9ebc\u6a23\uff0c\u4ee5\u4e0b\u5c31\u91dd\u5c0d\u5e7e\u5927\u985e\u52a0\u4ee5\u8aaa\u660e\uff1a<\/p>\n<h4>1xx<\/h4>\n<p>1\u958b\u982d\u7684\u4ee3\u8868<code><code>\u8a0a\u606f<\/code><\/code>\uff0c\u5ba2\u6236\u7aef\u7684\u8acb\u6c42\u5df2\u7d93\u88ab\u4f3a\u670d\u5668\u7d66\u63a5\u6536\u6216\u662f\u7e7c\u7e8c\u8655\u7406\u4e2d<\/p>\n<h4>2xx<\/h4>\n<p>2\u958b\u982d\u7684\u4ee3\u8868<code><code>\u6210\u529f<\/code><\/code>\uff0c\u5ba2\u6236\u7aef\u7684\u8acb\u6c42\u5df2\u7d93\u6210\u529f\u88ab\u4f3a\u670d\u5668\u63a5\u6536\u4ee5\u53ca\u7406\u89e3\u4e26\u4e14\u63a5\u53d7<\/p>\n<h4>3xx<\/h4>\n<p>3\u958b\u982d\u7684\u4ee3\u8868<code><code>\u91cd\u65b0\u5c0e\u5411<\/code><\/code>\uff0c\u5ba2\u6236\u7aef\u7684\u8acb\u6c42\u96d6\u7136\u88ab\u4f3a\u670d\u5668\u7d66\u63a5\u53d7\u4f46\u662f\u9700\u8981\u5f8c\u7e8c\u64cd\u4f5c\u624d\u80fd\u5b8c\u6210\u9019\u4e00\u8acb\u6c42<\/p>\n<h4>4xx<\/h4>\n<p>4\u958b\u982d\u7684\u4ee3\u8868<code><code>\u8acb\u6c42\u932f\u8aa4<\/code><\/code>\uff0c\u5ba2\u6236\u7aef\u7684\u8acb\u6c42\u542b\u6709\u8a5e\u6cd5\u932f\u8aa4\u6216\u8005\u7121\u6cd5\u88ab\u57f7\u884c<\/p>\n<h4>5xx<\/h4>\n<p>5\u958b\u982d\u7684\u4ee3\u8868<code><code>\u4f3a\u670d\u5668\u932f\u8aa4<\/code><\/code>\uff0c\u4f3a\u670d\u5668\u5728\u8655\u7406\u67d0\u500b\u5ba2\u6236\u7aef\u7684\u6b63\u78ba\u8acb\u6c42\u6642\u767c\u751f\u932f\u8aa4<\/p>\n<h2>\u98a8\u683c\/\u898f\u7bc4<\/h2>\n<p>\u56e0\u70barestful\u50c5\u662f\u4e00\u7a2e\u98a8\u683c\uff0c\u6240\u4ee5\u8aaa\u518d\u64b0\u5bebrestfulapi\u6c92\u6709\u5b8c\u5168\u9075\u7167\u4e0a\u8ff0\u898f\u7bc4\u4f86\u8655\u7406\u6703\u600e\u6a23\u5462?\u57fa\u672c\u4e0a&#8230;\u7576\u7136\u4e0d\u6703\u600e\u6a23\uff0c\u4f46\u662f\u5c31\u662f\u4f60\u8aaa\u8a71\u8ddf\u5225\u4eba\u8aaa\u7684\u8a71\u4e0d\u540c\u5982\u6b64\u800c\u5df2\uff0c\u6240\u4ee5\u9802\u591a\u9020\u6210\u96de\u540c\u9d28\u8b1b\u7684\u5c40\u9762\uff0c\u6240\u4ee5\u70ba\u4e86\u907f\u514d\u9019\u7a2e\u5c40\u9762\u767c\u4e0a\uff0c\u9084\u662f\u7167\u8457\u9019\u7a2e\u898f\u7bc4\u4f86\u8655\u7406\u5427\uff0c\u907f\u514d\u65e5\u5f8c\u62b1\u6028\u70ba\u4ec0\u9ebc\u90fd\u6c92\u6709\u4eba\u61c2\u4f60\u3002<\/p>\n<h1>\u5c0f\u7d50<\/h1>\n<p>\u6c92\u60f3\u5230\u8aaa\u660e\u91cd\u9ede\u6bd4\u5beb\u4ee3\u78bc\u9084\u56f0\u96e3\uff0c\u5e0c\u671b\u6c92\u6709\u8aa4\u4eba\u5b50\u5f1f\u7684\u5167\u5bb9\uff0c\u82e5\u662f\u6709\u8acb\u56de\u5fa9\u544a\u77e5\u4ee5\u4fbf\u4fee\u6539\uff0c\u8aaa\u660e\u5b8c\u898f\u7bc4\u5f8c\u5c31\u8981\u6e96\u5099\u958b\u59cb\u8aaa\u660e\u5982\u4f55\u64b0\u5bebrestfulapi\uff0c\u4e0d\u904erestfulapi\u662f\u4e00\u500b\u63a5\u53d7\u5ba2\u6236\u7aef\u9700\u6c42\u8655\u7406\u4e26\u56de\u8986\u7684\u4f3a\u670d\u5668\u64cd\u4f5c\uff0c\u6c92\u6709\u6642\u505a\u5ba2\u6236\u7aef\u8981\u600e\u9ebc\u78ba\u8a8d\u6240\u5beb\u7684\u5167\u5bb9\u662f\u6b63\u78ba\u7684\u5462?\u6240\u4ee5\u4e0b\u4e00\u90e8\u5206\u5148\u6559\u6388\u64b0\u5bebapi\u7684\u5229\u5668postman\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u656c\u8acb\u671f\u5f85\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u751a\u9ebc\u662frestful \u8aaa\u5230restful\u5c31\u4e0d\u80fd\u4e0d\u63d0\u90a6\u53cbkerkerj\u7684\u5f9e\u7121\u5230\u6709\u6253\u9020 RESTful API s &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.develop-note.com\/blog\/2018\/10\/14\/2019ironman-flask-restful-day13\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008\u7b2c\u5341\u5c46\u9435\u4eba\u8cfd flask-restful DAY13-\u641e\u61c2restful\u3009<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[162,4,5,3],"class_list":["post-372","post","type-post","status-publish","format-standard","hentry","category-develop","tag-2018ironman","tag-flask","tag-flask-restful","tag-python"],"_links":{"self":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/comments?post=372"}],"version-history":[{"count":24,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/372\/revisions"}],"predecessor-version":[{"id":2756,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/372\/revisions\/2756"}],"wp:attachment":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/media?parent=372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/categories?post=372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/tags?post=372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}