{"id":62493,"date":"2018-08-16T08:55:40","date_gmt":"2018-08-15T23:55:40","guid":{"rendered":"https:\/\/www.softantenna.com\/wp\/?p=62493"},"modified":"2018-08-16T08:55:40","modified_gmt":"2018-08-15T23:55:40","slug":"python-web-server","status":"publish","type":"post","link":"https:\/\/softantenna.com\/blog\/python-web-server\/","title":{"rendered":"\u3010Tips\u3011Python\u3092\u5229\u7528\u3057\u3066\u7c21\u6613Web\u30b5\u30fc\u30d0\u30fc\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p><img decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto;\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2018\/08\/s_20180814_222334.jpg\" alt=\"S 20180814 222334\" title=\"s_20180814_222334.jpg\" border=\"0\" width=\"827\" height=\"583\" \/><\/p>\n<p>\u73fe\u5728\u4e16\u754c\u4e2d\u3067\u4eba\u6c17\u3092\u96c6\u3081\u3066\u3044\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u300cPython\u300d\u3002<\/p>\n<p>\u3082\u3068\u3082\u3068\u6c4e\u7528\u6027\u306e\u9ad8\u3044\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3068\u3057\u3066\u5e83\u304f\u4f7f\u308f\u308c\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u6700\u8fd1\u306f\u6a5f\u68b0\u5b66\u7fd2\u30fb\u7d71\u8a08\u5206\u91ce\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3082\u5145\u5b9f\u3057\u3001\u6700\u5148\u7aef\u306e\u5206\u91ce\u3067\u591a\u304f\u4f7f\u7528\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u304d\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u306f\u3053\u306ePython\u3092\u5229\u7528\u3059\u308b\u3068\u3001\u7c21\u5358\u306a\u624b\u9806\u306b\u3088\u3063\u3066Web\u30b5\u30fc\u30d0\u30fc(HTTP\u30b5\u30fc\u30d0\u30fc)\u3092\u8d77\u52d5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u307e\u305f\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3059\u308b\u3060\u3051\u3067CGI\u3092\u547c\u3073\u51fa\u3057\u3066\u5b9f\u884c\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u305d\u306e\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<h2>Python\u3092\u5229\u7528\u3057\u3066Web\u30b5\u30fc\u30d0\u30fc\u3092\u8d77\u52d5\u3059\u308b\u65b9\u6cd5<\/h2>\n<p>Python 3.0\u4ee5\u964d\u3067\u306f\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u306b\u3088\u3063\u3066Web\u30b5\u30fc\u30d0\u30fc\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>\n$ python -m http.server\nServing HTTP on 0.0.0.0 port 8000 (http:\/\/0.0.0.0:8000\/) ...\n<\/pre>\n<p>\u753b\u9762\u306e\u6307\u793a\u901a\u308a\u30d6\u30e9\u30a6\u30b6\u3067\u300chttp:\/\/0.0.0.0:8000\/\u300d\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001\u4e0a\u8a18\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u305f\u30ab\u30ec\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306eindex.html\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u3059\u306a\u308f\u3061\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u30eb\u30fc\u30c8\u306b\u306a\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u300chttp:\/\/0.0.0.0:8000\/test.html\u300d\u306e\u5834\u5408\u306f\u3001\u30ab\u30ec\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306etest.html\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>CGI\u3092\u5b9f\u884c\u3057\u305f\u3044\u5834\u5408\u306f\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u300c-cgi\u300d\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>\n python -m http.server --cgi\nServing HTTP on 0.0.0.0 port 8000 (http:\/\/0.0.0.0:8000\/) ...\n<\/pre>\n<p>cgi\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u30ab\u30ec\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u4ee5\u4e0b\u306e\u300c\/cgi-bin\u300d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u300c.\/cgi-bin\/hello.py\u300d\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre>\n#!\/usr\/bin\/env python\n\nprint('Content-type: text\/html; charset=UTF-8\\r\\n')\nprint('Hello, World!')\n<\/pre>\n<p>\u30d6\u30e9\u30a6\u30b6\u3067\u300chttp:\/\/0.0.0.0:8000\/cgi-bin\/hello.py\u300d\u306b\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto;\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2018\/08\/s_20180814_222457.jpg\" alt=\"S 20180814 222457\" title=\"s_20180814_222457.jpg\" border=\"0\" width=\"875\" height=\"410\" \/><\/p>\n<p>\u25b2hello.py\u304c\u5b9f\u884c\u3055\u308c\u3066\u7d50\u679c\u304c\u753b\u9762\u306b\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>Python\u3092\u5229\u7528\u3059\u308c\u3070\u7c21\u6613\u7684\u306aWeb\u30b5\u30fc\u30d0\u30fc\u3092\u30ef\u30f3\u30e9\u30a4\u30ca\u30fc\u3067\u7acb\u3061\u4e0a\u3052\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002Web\u30da\u30fc\u30b8\u306e\u898b\u305f\u76ee\u306e\u78ba\u8a8d\u3092\u884c\u3044\u305f\u3044\u5834\u5408\u3084\u3001HTTP\u306e\u30c6\u30b9\u30c8\u3092\u884c\u3044\u305f\u3044\u5834\u5408\u306b\u5229\u7528\u3059\u308b\u3068\u4fbf\u5229\u306a\u6a5f\u80fd\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u73fe\u5728\u4e16\u754c\u4e2d\u3067\u4eba\u6c17\u3092\u96c6\u3081\u3066\u3044\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u300cPython\u300d\u3002 \u3082\u3068\u3082\u3068\u6c4e\u7528\u6027\u306e\u9ad8\u3044\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3068\u3057\u3066\u5e83\u304f\u4f7f\u308f\u308c\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u6700\u8fd1\u306f\u6a5f\u68b0\u5b66\u7fd2\u30fb\u7d71\u8a08\u5206\u91ce\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3082\u5145\u5b9f\u3057\u3001\u6700\u5148\u7aef\u306e\u5206\u91ce\u3067\u591a\u304f\u4f7f\u7528\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u3066 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":62516,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[2047],"tags":[703],"class_list":["post-62493","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips","tag-python"],"_links":{"self":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/62493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/comments?post=62493"}],"version-history":[{"count":0,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/62493\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media\/62516"}],"wp:attachment":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media?parent=62493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/categories?post=62493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/tags?post=62493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}