{"id":66,"date":"2022-10-19T10:49:34","date_gmt":"2022-10-19T10:49:34","guid":{"rendered":"https:\/\/gnose.cln4.net\/?p=66"},"modified":"2022-10-19T10:49:36","modified_gmt":"2022-10-19T10:49:36","slug":"core-x%e3%81%a7flask%e3%81%ae%e7%a8%bc%e5%83%8d%e3%81%a7%e8%ba%93%e3%81%84%e3%81%9f%e7%82%b9","status":"publish","type":"post","link":"https:\/\/gnose.cln4.net\/?p=66","title":{"rendered":"Core-X\u3067Flask\u306e\u7a3c\u50cd\u3067\u8e93\u3044\u305f\u70b9"},"content":{"rendered":"\n<p>Core-X\u306bPython\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u4f5c\u6210\u3057\u305fFlask\u30a2\u30d7\u30ea\u3092\u52d5\u304b\u3059\u3002\uff08CGI\u30e2\u30fc\u30c9\u3067\uff09<br>\u305d\u306e\u3055\u3044\u306b\u30cf\u30de\u3063\u305f\u3053\u3068\u3092\u30e1\u30e2\u66f8\u304d\u3002\u306a\u304a\u89e3\u6c7a\u3057\u3066\u3044\u306a\u3044\u3082\u306e\u3082\u3042\u308a\u307e\u3059\u3002\uff08\u539f\u56e0\u304c\u306a\u3093\u3060\u304b\u5206\u304b\u3089\u306a\u3044\u30fb\u30fb\u30fb\uff09<\/p>\n\n\n\n<p>\u3067\u3082\u7aef\u7684\u306b\u8a00\u3063\u3066\u3057\u307e\u3048\u3070\u3001\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u3082\u3057\u3063\u304b\u308a\u540c\u3058\u3088\u3046\u306a\u74b0\u5883\u3092\u7d44\u307f\u7acb\u3066\u3066\u8a66\u9a13\u3057\u3066\u304a\u3053\u3046\u306d\u3002\u3068\u3044\u3046\u8a71\u3067\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4>\u25a01.\u30b5\u30fc\u30d0\u30a8\u30e9\u30fc\uff08HTTP\u30b9\u30c6\u30fc\u30bf\u30b9\uff1a500\uff09\u306b\u306a\u308b<\/h4>\n\n\n\n<p>\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u306f\u52d5\u304f\uff08wsgi\u3067\uff09\u306e\u306b\u3001CORE-X\u3067CGI\u30e2\u30fc\u30c9\u3067\u52d5\u304b\u3059\u3068HTTP\u30b9\u30c6\u30fc\u30bf\u30b9\uff1a500\u3068\u306a\u308b\u3002<br>\u3067\u3001\u30a8\u30e9\u30fc\u30ed\u30b0\u3092\u78ba\u8a8d\u3057\u3088\u3046\u3068\u3059\u308b\u304c\u3001\u30a8\u30e9\u30fc\u30ed\u30b0\u81ea\u4f53\u304c\u51fa\u529b\u3055\u308c\u3066\u3044\u306a\u3044\u3002\u3002\u3002<\/p>\n\n\n\n<p>\u6700\u521d\u306f\u30d1\u30b9\u304c\u8aa4\u3063\u3066\u3044\u308b\u305b\u3044\u304b\u3068\u601d\u3044\u3001venv\u306e\u306a\u304b\u306epth\u30d5\u30a1\u30a4\u30eb\u7b49\u3092\u78ba\u8a8d\u3059\u308b\u304c\u554f\u984c\u306a\u3055\u305d\u3046\u3001\u30c6\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u7528\u610f\u3057\u3066\u30d1\u30b9\u3092\u51fa\u529b\u3059\u308b\u304c\u305d\u308c\u3067\u898b\u3066\u3082\u554f\u984c\u306a\u3055\u305d\u3046\u3001\u3001\u3001\u539f\u56e0\u304c\u5206\u304b\u3089\u306a\u3044\u306e\u3067\u3001\u4ed5\u65b9\u306a\u304f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u524a\u3063\u3066\u4e00\u3064\u4e00\u3064\u5b9f\u884c\u3002<\/p>\n\n\n\n<p>\u3067\u5206\u304b\u3063\u305f\u306e\u306f\u30eb\u30fc\u30c8\u30ed\u30ac\u30fc\u306b\u304a\u3044\u3066\u3001\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u3080\u3053\u3080\u6642\u70b9\u3067\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3044\u308b\u3053\u3068\u3002<br>\u30ed\u30b0\u51fa\u529b\u5148\u306b\u5bfe\u3057\u3066\u6a29\u9650\u304c\u7121\u3044\u306e\u304b\u306a\u3041\u2026\u3068\u601d\u3063\u305f\u304c\u305d\u3046\u3067\u3082\u306a\u3044\u3002\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u81ea\u4f53\u304c\u898b\u3048\u3066\u306a\u3044\uff1f\u3068\u601d\u3044\u8aad\u307f\u8fbc\u307f\u6642\u306e\u30d1\u30b9\u3092\u7d76\u5bfe\u30d0\u30b9\u306e\u30cf\u30fc\u30c9\u30b3\u30fc\u30c9\u306b\u3057\u3066\u307f\u308b\u304c\u540c\u3058\u307e\u307e\u3002<br><br>\u304b\u308c\u3053\u308c\uff12\u6642\u9593\u8fd1\u304f\u30a6\u30fc\u30f3\u30a6\u30fc\u30f3\u3068\u3084\u308a\u306a\u304c\u3089\u6c17\u304c\u3064\u3044\u305f\u306e\u306f\u3001\u30ed\u30b0\u51fa\u529b\u306b\u304a\u3044\u3066<br>\u30d5\u30a1\u30a4\u30eb\u51fa\u529b\u3068\u30b3\u30f3\u30bd\u30fc\u30eb\u51fa\u529b\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3002<\/p>\n\n\n\n<p>\u25cf\u30ed\u30ac\u30fc\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;logger_root]\nlevel=DEBUG\nhandlers=<strong>consoleHandler<\/strong>,fileHandler \u2190\u3053\u306econsoleHandler\u304c\u539f\u56e0\u3067\u52d5\u304b\u306a\u304b\u3063\u305f\n\n&#91;handler_consoleHandler]\nclass=StreamHandler\nlevel=INFO\nformatter=simpleFormatter\nargs=(sys.stdout,)<\/code><\/pre>\n\n\n\n<p>\u78ba\u304b\u306bFlask\u306e\u30da\u30fc\u30b8\u3092\u898b\u3066\u3082\u3001CGI\u3067\u52d5\u304b\u3059\u969b\u306b\u306f\u30b3\u30fc\u30c9\u306e\u4e2d\u306bprint\u306a\u3069\u5165\u308c\u308b\u306a\u3068\u66f8\u304b\u308c\u3066\u3044\u308b\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/msiz07-flask-docs-ja.readthedocs.io\/ja\/latest\/deploying\/cgi.html\" target=\"_blank\" rel=\"noreferrer noopener\">Flask CGI<\/a><\/p>\n\n\n\n<p>\u3053\u306e\u3053\u3068\u81ea\u4f53\u306f\u77e5\u3063\u3066\u3044\u305f\u304c\u3001\u30ed\u30b0\u51fa\u529b\u306f\u898b\u843d\u3068\u3057\u3066\u3044\u305f\u3002\u3002\u3002<br>\u30fb\u30fb\u30fb\u306a\u304a\u305f\u3060\u5358\u306bprint\u3092\u5165\u308c\u305f\u5834\u5408\u3001response\u306b\u8ffd\u52a0\u3055\u308c\u308b\uff1f  jsonify\u3067\u8fd4\u3059\u3068\u3053\u308d\u3067\u3001\u30d1\u30fc\u30b9\u7528\u306e\u30af\u30e9\u30b9(default\u306e\u51e6\u7406)\u306b\u304a\u3044\u3066print\u3092\u8ffd\u52a0\u3057\u305f\u3089\u3001json\u306e\u3042\u3068\u306bprint\u306e\u51fa\u529b\u304c\u8ffd\u52a0\u3055\u308c\u3001javascript\u3067parsererror\u306b\u306a\u3063\u305f\u3002<br>  \u3060\u3051\u3069\u30b3\u30f3\u30bd\u30fc\u30eb\u306e\u30ed\u30b0\u51fa\u529b\u3060\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308b\u306e\u304b\uff1f<br><br>\u4eca\u5f8c\u6c17\u3092\u3064\u3051\u305f\u3044\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4>\u25a02.URL_FOR \u306e\u30d1\u30b9\u304c\u5408\u308f\u306a\u3044<\/h4>\n\n\n\n<p>Jinja\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u826f\u304f\u4f7f\u3046&#8221;URL_FOR&#8221;\u3002<br>\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u306fwsgi\u3067\u4f5c\u6210\u3057\u3066\u3044\u305f\u305f\u3081\u3001\u7279\u6bb5\u554f\u984c\u306a\u304furl_for\u3067\u6b63\u3057\u3044URL\u3092\u6307\u3057\u793a\u3057\u3066\u304f\u308c\u308b\u306e\u3060\u304c\u3001<br>CGI\u30e2\u30fc\u30c9\u3067\u7a3c\u50cd\u3055\u305b\u308b\u3068\u6b63\u3057\u3044URL\u3092\u793a\u3055\u306a\u3044\u3002<\/p>\n\n\n\n<p>\u307e\u3041\u7406\u5c48\u3067\u8003\u3048\u308b\u3068CGI\u30e2\u30fc\u30c9\u3067\u7a3c\u50cd\u3055\u305b\u308b\u305f\u3081\u306b\u3001.htaccess\u30d5\u30a1\u30a4\u30eb\u306b\u304a\u3044\u3066rewrite\u30e2\u30fc\u30b8\u30e5\u30eb\u3067URL\u3092\u5909\u66f4\u3057\u3066\u3044\u308b\u305f\u3081\u3001\u5909\u66f4\u3055\u308c\u305furl\u304c\u8ffd\u52a0\u3055\u308c\u30d1\u30b9\u304c\u5408\u308f\u306a\u304f\u306a\u308b\u3002<\/p>\n\n\n\n<p>\u25cf.htaccess<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RewriteEngine On\nRewriteCond %{REQUEST_FILENAME} !-f # Don't interfere with static files\nRewriteRule ^(.*)$ index.cgi\/$1 &#91;L]<\/code><\/pre>\n\n\n\n<p>\u25cfindex.cgi<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from wsgiref.handlers import CGIHandler\nfrom test.web_app import app\n\nCGIHandler().run(app)<\/code><\/pre>\n\n\n\n<p>\u25cfwsgi\u306e\u3068\u304d<br> url_for(&#8220;static&#8221; , filename=&#8221;test.css&#8221;) \u21d2 https:\/\/xx.xx.xx\/static\/test.html<\/p>\n\n\n\n<p>\u25cfcgi\u306e\u3068\u304d<br> url_for(&#8220;static&#8221; , filename=&#8221;test.css&#8221;) \u21d2 https:\/\/xx.xx.xx\/<strong>index.cgi\/yyyy.html\/<\/strong>static\/test.html<\/p>\n\n\n\n<p>\u306e\u3088\u3046\u306b\u3001wsgi\u3067\u306f\u6b63\u5e38\u3060\u3063\u305f\u304c\u3001cgi\u3067\u306f\u4f59\u8a08\u306a\u30d1\u30b9\u304c\u3064\u3044\u3066\u4e0a\u624b\u304f\u52d5\u304b\u306a\u3044\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>.htaccess\u3067\u5909\u63db\u30eb\u30fc\u30eb\u3092\u3061\u3083\u3093\u3068\u4f5c\u308c\u3070\u4e0a\u624b\u304f\u51fa\u6765\u308b\u306e\u304b\u3082\u3057\u308c\u306a\u3044\u304c\u3001<br>rewrite\u306e\u5909\u63db\u30eb\u30fc\u30eb\u306e\u8a18\u8ff0\u304c\u3088\u304f\u308f\u304b\u3089\u305a\u3001\u3081\u3093\u3069\u3046\u306b\u306a\u3063\u305f\u305f\u3081\u3001\u7d50\u5c40url_for\u3067\u8a18\u8ff0\u3057\u3066\u3044\u305f\u90e8\u5206\u3092\u30cf\u30fc\u30c9\u30b3\u30fc\u30c9\u3067\u30d1\u30b9\u3092\u8a18\u8f09\u3057\u305f\u3002<br><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Core-X\u306bPython\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u4f5c\u6210\u3057\u305fFlask\u30a2\u30d7\u30ea\u3092\u52d5\u304b\u3059\u3002\uff08CGI\u30e2\u30fc\u30c9\u3067\uff09\u305d\u306e\u3055\u3044\u306b\u30cf\u30de\u3063\u305f\u3053\u3068\u3092\u30e1\u30e2\u66f8\u304d\u3002\u306a\u304a\u89e3\u6c7a\u3057\u3066\u3044\u306a\u3044\u3082\u306e\u3082\u3042\u308a\u307e\u3059\u3002\uff08\u539f\u56e0\u304c\u306a\u3093\u3060\u304b\u5206\u304b\u3089\u306a\u3044\u30fb\u30fb\u30fb\uff09 \u3067\u3082\u7aef [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/gnose.cln4.net\/index.php?rest_route=\/wp\/v2\/posts\/66"}],"collection":[{"href":"https:\/\/gnose.cln4.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gnose.cln4.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gnose.cln4.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gnose.cln4.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=66"}],"version-history":[{"count":1,"href":"https:\/\/gnose.cln4.net\/index.php?rest_route=\/wp\/v2\/posts\/66\/revisions"}],"predecessor-version":[{"id":67,"href":"https:\/\/gnose.cln4.net\/index.php?rest_route=\/wp\/v2\/posts\/66\/revisions\/67"}],"wp:attachment":[{"href":"https:\/\/gnose.cln4.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=66"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gnose.cln4.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=66"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gnose.cln4.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=66"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}