{"id":415,"date":"2019-01-02T13:16:21","date_gmt":"2019-01-02T04:16:21","guid":{"rendered":"http:\/\/int-info.com\/?page_id=415"},"modified":"2023-04-14T22:59:33","modified_gmt":"2023-04-14T13:59:33","slug":"bottle-python","status":"publish","type":"page","link":"http:\/\/int-info.com\/index.php\/bottle-python\/","title":{"rendered":"PyLearnWEB 01"},"content":{"rendered":"<h4 style=\"padding: 0.1em 0.3em; border-left: 10px solid #1E88E5; border-bottom: 3px solid #B0BEC5;\"> \u74b0\u5883\u69cb\u7bc9 <\/h4>\n<p>\n&#8220;bottle.py&#8221;\u3092\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u7f6e\u3051\u3070\u3001\u305d\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u30bf\u30fc\u30df\u30ca\u30eb\u3067\u3001\u4f5c\u696d\u3092\u3057\u305f\u3044\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u79fb\u52d5\u3057\u3001wget\u30b3\u30de\u30f3\u30c9\u3067&#8221;bottle.py&#8221;\u3092\u5165\u624b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n<\/p>\n<p>\nwget https:\/\/github.com\/bottlepy\/bottle\/raw\/master\/bottle.py\n<\/p>\n<p>\nwget\u30b3\u30de\u30f3\u30c9\u304c\u4f7f\u3048\u306a\u3044\u3068\u304d\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067wget\u3092\u4f7f\u7528\u53ef\u80fd\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n<\/p>\n<p>\nbrew install wget\n<\/p>\n<p><\/br><\/p>\n<h4 style=\"padding: 0.1em 0.3em; border-left: 10px solid #1E88E5; border-bottom: 3px solid #B0BEC5;\"> \u30b5\u30fc\u30d0\u306e\u8d77\u52d5 <\/h4>\n<p>bottle.py\u304c\u3042\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3001\u4ee5\u4e0b\u306esample.py\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<pre class=\"lang:python decode:true \" title=\"sample.py\" >from bottle import route, run\r\n\r\n@route(\"\/\")\r\ndef index():\r\n    return \"Hello!\"\r\n\r\nrun(reloader=True, port=9999)<\/pre>\n<p>\u305d\u306e\u5f8c\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u3067sample.py\u3092\u5b9f\u884c\u3059\u308b\u3002<br \/>\n(atom\u3067\u958b\u3044\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u2192Script\u2192Run Script\u3067ok\u3067\u3059)<\/p>\n<pre class=\"lang:default decode:true \" title=\"Terminal\">python3 sample.py<\/pre>\n<p>\u3059\u308b\u3068\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u306b\u4ee5\u4e0b\u306e\u6587\u7ae0\u304c\u3042\u308b\u306e\u3067\u3001Web\u30d6\u30e9\u30a6\u30b6\u3092\u958b\u304d\u3001URL\u306b\u6253\u3061\u8fbc\u3080\u3002<\/p>\n<pre class=\"lang:default decode:true \" title=\"Terminal\">Bottle v0.13-dev server starting up (using WSGIRefServer())...\r\nListening on http:\/\/xxx.xxx.xxx.xxx:9999\/\r\nHit Ctrl-C to quit.<\/pre>\n<p>\u30d6\u30e9\u30a6\u30b6\u306b\u3001Hello!\u3068\u51fa\u3066\u5165\u308c\u3070ok\u3067\u3059\u3002\u30b5\u30fc\u30d0\u306e\u8d77\u52d5\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002<br \/>\n@route(&#8220;\/&#8221;)\u306f\u3001\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u30eb\u30fc\u30c8\u3001\u3064\u307e\u308a\u3001\u30b5\u30fc\u30d0\u306eip\u30a2\u30c9\u30ec\u30b9\u3092URL\u306b\u5165\u308c\u305f\u6642\u306b\u8868\u793a\u3055\u308c\u308b\u30da\u30fc\u30b8\u3067\u3042\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u3066\u3044\u307e\u3059\u3002index\u95a2\u6570\u306ereturn\u306bHTML\u3092\u5165\u308c\u308b\u3068\u3001\u305d\u306e\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u3068\u8a00\u3046\u4ed5\u7d44\u307f\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304f\u3068\u3001\u30dc\u30bf\u30f3\u304c\u51fa\u3066\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:python decode:true \" title=\"sample.py\" >from bottle import route, run\r\n\r\n@route(\"\/\")\r\ndef index():\r\n    HTMLtext = '<html>'\r\n    HTMLtext = HTMLtext + '&lt;head>'\r\n    HTMLtext = HTMLtext + '&lt;title> PythonHTML &lt;\/title>'\r\n    HTMLtext = HTMLtext + '&lt;\/head>'\r\n    HTMLtext = HTMLtext + '&lt;body>'\r\n    HTMLtext = HTMLtext + '&lt;p>Go to the Top Page&lt;\/p>'\r\n    HTMLtext = HTMLtext + '&lt;input type=\"submit\" value=\"button!\" onclick=\"location.href=\\'http:\/\/int-info.com\\'\">'\r\n    HTMLtext = HTMLtext + '&lt;\/a>'\r\n    HTMLtext = HTMLtext + '&lt;\/body>'\r\n    HTMLtext = HTMLtext + '&lt;\/html>'\r\n    return HTMLtext\r\n\r\nrun(reloader=True, port=9999)<\/pre>\n<p><\/br><\/p>\n<p>\u306a\u304a\u3001\u4ee5\u4e0b\u306e\u8a18\u8ff0\u306f\u3001\u30dc\u30bf\u30f3\u304c\u62bc\u3055\u308c\u305f\u6642\uff08onclick\uff09\u306bhttp:\/\/int-info.com\u306b\u98db\u3076\u3001\u3068\u3044\u3046\u610f\u5473\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre>\r\n&lt;input type=\"submit\" value=\"button!\" onclick=\"location.href=\\'http:\/\/int-info.com\\'\">\r\n<\/pre>\n<p><\/br><\/p>\n<h4 style=\"padding: 0.1em 0.3em; border-left: 10px solid #1E88E5; border-bottom: 3px solid #B0BEC5;\"> \u30c7\u30d0\u30c3\u30b0\u74b0\u5883 <\/h4>\n<p>\u66f8\u3044\u3066\u304a\u304f\u3068\u3001\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u3068\u304d\u306b\u30d6\u30e9\u30a6\u30b6\u306b\u7406\u7531\u3092\u8a18\u8f09\u3057\u3066\u304f\u308c\u307e\u3059\u3002<br \/>\nfrom bottle import debug<br \/>\ndebug(True)<\/p>\n<p><\/br><\/p>\n<h4 style=\"padding: 0.1em 0.3em; border-left: 10px solid #1E88E5; border-bottom: 3px solid #B0BEC5;\"> \u30a8\u30e9\u30fc\u5bfe\u5fdc <\/h4>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u304b\u3089\u300caddress already use\u300d\u307f\u305f\u3044\u306a\u30a8\u30e9\u30fc\u304c\u8fd4\u3063\u3066\u304f\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u306f\u30b5\u30fc\u30d0\u3092\u9069\u5207\u306b\u505c\u6b62\u3055\u305b\u306a\u304b\u3063\u305f\u5834\u5408\u306b\u8d77\u3053\u308a\u307e\u3059\u3002<\/p>\n<p>lsof -i :9999<\/p>\n<p>\u3068\u3001python\u3067\u6307\u5b9a\u3057\u3066\u3044\u308b\u30dd\u30fc\u30c8\u756a\u53f7\u3092\u6253\u3061\u307e\u3059\u3002\u3059\u308b\u3068\u3001\u8d77\u52d5\u4e2d\u306ePID\u306e\u6570\u5b57\u304c\u5e30\u3063\u3066\u304f\u308b\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u6253\u3061\u307e\u3059\u3002<\/p>\n<p>kill xxx<\/p>\n<p>xxx\u306fPID\u306e\u6570\u5b57\u3067\u3059\u3002\u3059\u308b\u3068\u3001\u30b5\u30fc\u30d0\u304c\u505c\u6b62\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u74b0\u5883\u69cb\u7bc9 &#8220;bottle.py&#8221;\u3092\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u7f6e\u3051\u3070\u3001\u305d\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u30bf\u30fc\u30df\u30ca\u30eb\u3067\u3001\u4f5c\u696d\u3092\u3057\u305f\u3044\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u79fb\u52d5\u3057\u3001wget\u30b3\u30de\u30f3\u30c9\u3067&#8221;bo<\/p><\/div>\n<div class=\"blog-btn\"><a href=\"http:\/\/int-info.com\/index.php\/bottle-python\/\" class=\"home-blog-btn\">\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-415","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/pages\/415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/comments?post=415"}],"version-history":[{"count":23,"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/pages\/415\/revisions"}],"predecessor-version":[{"id":3563,"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/pages\/415\/revisions\/3563"}],"wp:attachment":[{"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/media?parent=415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}