è€æ°ã®Windowsããã³Linuxã³ã³ãã¥ãŒã¿ãŒãæ§æããŸããããœãŒã¹ã³ãŒãã¯Dropboxãä»ããŠåæããããã€ã¯ãã€ã³ã¹ã¿ã³ã¹ã¯Amazon EC2ã§ã»ããã¢ãããããŸãã ããã«ã¯ãã¹ãŠæéãããããããŸã䟿å©ã§ã¯ãããŸããããçŸå Žãã§ã¢ã€ãã¢ã確èªãããå ŽåããããŸãããŸããè¿ãã«ææ ã®ããç°å¢ã¯ãããŸããã PythonAnywhereã¯äœãæäŸããŸããïŒ
é·ã説æãèªãåã«ããµãŒãã¹ã«ã€ããŠç°¡åã«èª¬æããŠãããããªãèŠãããšããå§ãããŸãã
ãŸããPyCon UK 2011ã®Harry Percivaléçºè ã«ãããã¬ãŒã³ããŒã·ã§ã³ãèªãããšãã§ããŸãïŒè±èªã®ç¥èã¯å€§æè¿ã§ããããã¬ãŒã³ããŒã·ã§ã³ããªããã°ããã¬ãŒã³ããŒã·ã§ã³ããå€ããç解ã§ããŸãïŒã
ã¹ããŒãã®æåŸã«ãããªãŒã¯ååãªæéãæã£ãŠããªãã£ãã®ã§ããã€ã¯ãåãå»ãããªãããã«ããŒã«ãèµ°ãåããªããã°ãªããŸããã§ããã
ã€ã³ã¿ãŒãããã§ã®Pythonã®ããã°ã©ãã³ã°
PythonAnywhereã¯ããã©ãŠã¶ã§çŽæ¥Pythonãéçºã§ããç°å¢ã«å ããŠããããã®ãããžã§ã¯ãããã¹ãããŠããŸãã ãã©ãŠã¶ãšã€ã³ã¿ãŒãããã¢ã¯ã»ã¹ãããã°ãå¿ èŠãªãã®ã¯ãã¹ãŠæã£ãŠããŸãã ãµãŒããŒã¯æ¢ã«æ§æãããŠãããå¿ èŠãªãã®ãæã£ãŠããŸãã ããã§ãéçºç°å¢ãç°¡åã«æã¡æ©ãããšãã§ããŸããäœæ¥äžã®ã³ã³ãã¥ãŒã¿ãŒã§ãããžã§ã¯ããéå§ããäžæãããšããããç¶è¡ããŸãããæ¢ã«ã©ãããããäžã«ãããŸãã
iPadã®ææè ãåå©ãåããŸããïŒ
ããã§ãPythonã®æ œå¹è ã¯ã以åã®ã³ã³ãã¥ãŒã¿ãŒã§è¡ã£ãŠããã®ãšåããããç°¡åã«ãiPadãé»è©±ããŸãã¯ã¹ããŒããã¬ãïŒã¹ããŒããã¬ãïŒã§ã¢ããªã±ãŒã·ã§ã³ãäœæã§ããŸãã PythonAnywhereã¯iPadã§å®è¡ãããŠãããAndroidããŒãžã§ã³ã¯ãŸããªãæºåãæŽããŸãã Webãšãã£ã¿ãŒã§ããã°ã©ã ãèšè¿°ããããHTML5ããµããŒãããææ°ã®ãã©ãŠã¶ãŒã§ã³ã³ãœãŒã«ã»ãã·ã§ã³ãéå§ãããã§ããŸãã ç¬èªã®ãµãŒããŒãæ§æãããããã®æ§æã«æéãæ¯æãå¿ èŠã¯ãããããŸããã
ãããŠãèå°è£ã«ã¯äœããããŸããïŒ
PythonAnywhereã¯AmazonãµãŒããŒïŒEC2ïŒã䜿çšããŠããããã®ã¢ãããŒããæ倧éã«æŽ»çšã§ããŸãã ç°¡åãªã¢ããªã±ãŒã·ã§ã³ãè¿ éã«éçºããããã«ã1ãæãæ¯æãå¿ èŠã¯ãããŸããã ãŸãã匷åã§ãªãœãŒã¹ã倧éã«æ¶è²»ããã¿ã¹ã¯ã®å Žåã䜿çšãããªãœãŒã¹ã«å¯ŸããŠã®ã¿æ¯æããŸãã
ããã«ãDropBoxãšã®çµ±åããããããŒã¿ãšã³ãŒããåæã§ããŸãã ã³ãã³ãã©ã€ã³ã䜿çšãããšãGitHubãBitbucketãããã³ãã®ä»ã®ãããªãã¯ãªããžããªã§gitãmercurialããŸãã¯subversionãããžã§ã¯ããç°¡åã«æäœã§ããŸãã
PythonããŒãžã§ã³2.6ã2.7ãããã³3.2ãå©çšå¯èœã§ãã NumPyãSciPyãMechanizeãBeautifulSoupãpycryptoãªã©ã®å€ãã®ã©ã€ãã©ãªãã€ã³ã¹ããŒã«ãããŠããŸã ã ãã®ã»ããã§ã¯äžååãªå Žå-easy_installãšpipãããã-userãã©ã°ã䜿çšããã ãã§ãããŒã ãã©ã«ããŒã®.localãã£ã¬ã¯ããªã§ã€ã³ã¹ããŒã«ãå®è¡ãããŸãã ãŸããvirtualenvãšvirtualenvwrapperãè¿œå ãããŸããã
Djangoã ãããµããŒããããŠããããã§ã¯ãããŸããïŒFlaskãBottleãweb2py-WSGI Webãã¬ãŒã ã¯ãŒã¯ã¯ãã¹ãŠåäœããã»ãšãã©ã®å Žåæ¢ã«ã€ã³ã¹ããŒã«ãããŠããŸãïŒ ããããªãŒãåç §ïŒã MySQLãšSQLiteãããŒã¿ããŒã¹ãšããŠäœ¿çšã§ããŸããMongoDBãšPostgreSQLãè¿œå ããå¯èœæ§ãèæ ®ãããŸãã
æãé«äŸ¡ãªïŒæé¡10ãã«ããã¡ã€ã«ã®2GBãSSHïŒæéãã©ã³ã§ã¯ãç¬èªã®ãã¡ã€ã³ããã¹ãã§ããç¡æã®æéã§ã¯ãyour-username.pythonanywhere.comã®åœ¢åŒã®ãµããã¡ã€ã³ãæäŸãããŸãã æå°éã®å¶éã§ç¡æã®é¢çš-500MBã®ãã£ã¹ã¯å®¹éãå©çšå¯èœã§ãSSHã¯äœ¿çšã§ããŸããã
cronã«é¡äŒŒããŠããŸã-ã¹ã¯ãªããïŒPythonã ãã§ãªãïŒãã¹ã±ãžã¥ãŒã«ã«åŸã£ãŠå®è¡ã§ããŸãã
ã¢ã¯ã»ã¹ãã°ãšWebãµãŒããŒãšã©ãŒã確èªã§ããŸãã
ä»äºãå§ãã
ç»é²ã«ã¯ããã»ã©æéã¯ããããŸãããã¡ãŒã«ã¢ãã¬ã¹ã確èªãããããã«ãµãŒãã¹ã®äœ¿çšãéå§ã§ããŸãã
Ipythonãè©ŠãïŒ
DjangoããŒãžã§ã³1.3.1ã easy_installã䜿çšãããšãåé¡ãªãDjangoãææ°ã®ãªãªãŒã¹1.4ã«ã¢ããã°ã¬ãŒãã§ããŸããã
easy_install --user --upgrade django
æ°ããDjangoãããžã§ã¯ããäœæããŸãããã®ããã«ãWebã¿ãã«ç§»åãããNew Django Appããšãã倧ããªãã¿ã³ãã¯ãªãã¯ããŸãã
Webãã¬ãŒã ã¯ãŒã¯ã䜿çšããªãéåžžã®Pythonãããžã§ã¯ãã®å Žåã¯ã[ãã¡ã€ã«]ã¿ãã§ãã¡ã€ã«ãäœæããããã«Webãšãã£ã¿ãŒã«å ¥ããŸãã ç·šéãå®äºããããå®æãããã¡ã€ã«ãä¿åããŠããã«å®è¡ã§ããŸããã¹ã¯ãªãããå®è¡ãããã³ã³ãœãŒã«ã§ãããã¢ãããŠã£ã³ããŠãéããŸãã
Djangoãç¶ããŸããã-ãããžã§ã¯ãã®ååãšãããä¿åãããã©ã«ããŒãå ¥åããããã«æ±ããããŸãïŒ
ããã©ã«ãã®ãã©ã«ããŒã䜿çšãããããããžã§ã¯ããDropBoxã«ä¿åã§ããŸãã
DropBoxã«é¢é£ããå°ããªãã¥ã¢ã³ã¹ïŒ
1ïŒPythonAnywhereã®ã¡ãŒã«ã¢ãã¬ã¹ãDropBoxã®ã¡ãŒã«ã¢ãã¬ã¹ãšäžèŽããããšãæãŸãã-ãdropbox@pythonanywhere.comãã®ãããžã§ã¯ããã©ã«ããŒãå ±æãããã®ãã©ã«ããŒãã¢ã«ãŠã³ããšé¢é£ä»ããå¿ èŠããããŸãã ã¡ãŒã«ãäžèŽããªãå Žå-å³äžã®[ãã¡ã€ã«]ã¿ãã§[DropBoxã«æ¥ç¶]ãªã³ã¯ãã¯ãªãã¯ããDropBoxã§ã¡ãŒã«ãæå®ããŸãã ãã®ãµãŒãã¹ã®ãã©ã«ããDropBoxã§å ±æããæ¹æ³ãåçã§ç€ºããŸãã
2ïŒã/ Dropboxãã£ã¬ã¯ããªã«ãããžã§ã¯ããçŽæ¥äœæããããšã¯ã§ããŸãã-ãµããã£ã¬ã¯ããªã䜿çšããå¿ èŠããããŸãïŒã/ Dropbox / PythonAnywhereProjects / myprojectã ãã¯ãã«ã«ãµããŒãã¯ãããã¯äžæçãªçŸè±¡ã§ããããšã瀺åããŠããŸãã圌ãã¯ãçŸåšãµãŒãã¹ãéçºãããŠããããŸã æ©èœãå¶éãããŠãããšèšããŸãã
3ïŒDropboxããå ±æãã©ã«ããŒãåé€ããããšã¯ã§ããŸããããã®å Žåãå ±æãã©ã«ããŒã¯åžžã«PythonAnywhereã«æ®ããã³ã³ãœãŒã«ãããåé€ããããšã¯ã§ããŸããã ããã«å¯Ÿããã¢ã¯ã»ã¹æš©ã¯ãããŸããã ãããã£ãŠããŸãDropBox Webãµã€ãã§ããŠãŒã¶ãŒãdropbox@pythonanywhere.comãã®å ±æãã©ã«ããŒãžã®ã¢ã¯ã»ã¹ãåé€ããŸãã ãã®åŸããã©ã«ããŒã¯PythonAnywhereããæ¶ããDropBoxã§å®å šã«åé€ã§ããŸãã
ããã§ãç§ã¯DropBoxåæã䜿çšããŸããã
ç§ãã¡ã¯ãã§ãã¯ããŸãïŒ
次ã«-å¿ èŠãªãã¡ã€ã«ãäœæããWebãšãã£ã¿ãŒã§ç·šéããŸãïŒãŸãã¯bashã³ã³ãœãŒã«ã§vim / emacsãå®è¡ããŸãïŒã Djangoãããžã§ã¯ãã§ã¢ããªã±ãŒã·ã§ã³ãäœæããå¿ èŠãããå Žåã¯ãbashã³ã³ãœãŒã«ã䜿çšããŸãã
./manage.py startapp myapp
ãŠãŒã¶ãŒãã¹ã¯ãŒããèšå®ããå Žæãšåãå Žæã«ãã¿ããMySQLãã§ããŒã¿ããŒã¹ãäœæããŸãã
ãã¡ã€ã«ãäœæããããWebãµãŒããŒãåèµ·åããå¿ èŠããããŸãã ãããè¡ãã«ã¯ã[Web]ã¿ãã®[Webã¢ããªã®åèªã¿èŸŒã¿]ãã¿ã³ã䜿çšããŸãã
åæã«è€æ°ã®Webã¢ããªã±ãŒã·ã§ã³ãå®è¡ããå Žåããã¯ãã«ã«ãµããŒãã¯åãé»åã¡ãŒã«ã§è€æ°ã®ã¢ã«ãŠã³ããäœæããããšãææ¡ããŸããå°æ¥çã«ã¯1ã€ã®ã¢ã«ãŠã³ãã§ãã®ãããªæ©äŒããããŸãã
ãã®ä»ã®çšé
ååãšçžè«ããå¿ èŠãããå ŽåããããŸããã©ã®ã»ãã·ã§ã³ã§ãç°¡åã«å ±æã§ããŸãã æ¥ç¶ããããã«ãååã¯ãµãŒãã¹ã«ç»é²ããå¿ èŠãããããŸãããã¡ãŒã«ã¢ãã¬ã¹ãæå®ããã ãã§ãçŸåšã®ã³ã³ãœãŒã«ã»ãã·ã§ã³ãžã®ãªã³ã¯ãåãåããŸãã
段éçãªäŸã®ããããã°ã©ãã³ã°ããã°ããæã¡ã®å Žåã¯ãããã°ããŒãžã§èªè ãããã°ã©ãã³ã°ãå®è·µã§ããããã«ããããšãã§ããŸãã ãã®ã³ãŒããè¿œå ããã ãã§ãïŒ
<iframe style="width: 640px; height: 480px; border: none;" name="embedded_python_anywhere" src="https://www.pythonanywhere.com/embedded/"> </iframe>
åãªãŒããŒã¯ç¬èªã®ã³ã³ãœãŒã«ãåãåããããŒãžããããŒãžãžã®ç§»è¡äžã«ãã®ç¶æ ãä¿æãããŸãã
ãŸãã¯ããªãã©ã€ã³ã®Pythonããã°ã©ãã³ã°ã³ãŒã¹ãåè¬ããŸããã ãã¹ãŠã®æ°åè ãããªãã®æå°ã®äžã§ç°å¢ã®ã»ããã¢ãããå®äºããããæåã®ã¬ãã¹ã³ãåŸ ã€ã®ã¯æ®å¿µã§ãã 代ããã«ãPythonAnywhereã«ãµã€ã³ã¢ããããŠãæ°ååŸã«åŠç¿ããã»ã¹ã®éå§ã«æ¥ãããææ¡ã§ããŸãã
Pythonã§ç«ã¡åŸçããªãã§ãã ãããbashã³ã³ãœãŒã«ããããŸãã ããšãã°ããµãŒãããŒãã£ã®ãã¹ãïŒãµãŒãã¹ãæäŸããŠãããµãŒããŒãªã©ïŒãšã®æ°žç¶çãªSSHæ¥ç¶ãç¶æã§ããŸãã ãã®åŸãæ¥ã«æ¥ç¶ããå¿ èŠããããããšãã°ãã©ãŠã¶ã§ååãªå Žåãªã©ã«ã¢ã¯ã»ã¹ããå Žåãã³ã³ãœãŒã«ã¯ããã®ãŸãŸã®ç¶æ ã§åŸ æ©ããŠããŸãã
ããã¯ãGoogle App EngineïŒããã³å Žåã«ãã£ãŠã¯ææã®Pythonãã¹ãã£ã³ã°ïŒã®ä»£æ¿ãšããŠãé©ããŠããŸãã ä»ã®ãªãã·ã§ã³ãæãä»ãããšãã§ãããšç¢ºä¿¡ããŠããŸãã