The python scripts in this page and in the next one will try to save an uploaded file in a directory named files in the directory where it is running. If the directory where the script is running is /path/to/dir then the /path/to/dir/files directory must exist. If it does not it will fail. To upload a file the HTML form must have the enctype attribute set to multipart/form-data. The input tag with
CGIã¹ã¯ãªããã£ã³ã°ã®ä¸çãå¸å·»ãã¦ããè¨èªãPerlãªã®ã¯ç¢ºãã ããPerlããåªãã¦ããã¯ãã®ãã¼ã«ãå¹¾ã¤ãåå¨ãã¦ãããæ¬ç¨¿ã§ã¯Pythonãç¨ããCGIã¹ã¯ãªããã£ã³ã°ã®ä¸çãç°¡åã«ç´¹ä»ãããã Webéçºè ã«Common Gateway Interfaceï¼CGIï¼ã¹ã¯ãªããã£ã³ã°ã«ã¤ãã¦ã®è³ªåãããã¨ãè¿ã£ã¦ãã大å¤æ°ã®åçã¯ãããããPerlã使ã£ã¦ãã¾ããã¨ãããã®ã ãããããªã以åããCGIã¹ã¯ãªããã£ã³ã°ã®ä¸çãå¸å·»ãã¦ããè¨èªãPerlã§ããã®ã¯ç¢ºãã ãããã以å¤ã®é¸æè¢ããªã訳ã§ããªãããããPerlããåªãã¦ããã¯ãã®ãã¼ã«ãå¹¾ã¤ãåå¨ãã¦ããã®ã§ããããã£ã¦æ¬ç¨¿ã§ã¯1ã¤ã®ãã¥ã¼ããªã¢ã«ã¨ãã¦ãé«éãã¤å¤æ©è½ã§ãã«ããã©ãããã©ã¼ã ã«å¯¾å¿ããPythonãç¨ããCGIã¹ã¯ãªããã£ã³ã°ã®ä¸çãç°¡åã«ç´¹ä»ãããã¨ã«ãããã ã¤ã³ã¿ããªã¿åã®ãªãã¸ã§ã¯ãæåè¨èªã¨ãã¦
ã¦ã¼ã¶IDã¨ã»ãã·ã§ã³IDã®ã¯ããã¼ãéä¿¡ããã ã»ãã·ã§ã³IDã¯ãã©ã¦ã¶ãçµäºããã¾ã§æ®ããã¦ã¼ã¶IDã¯ãªã¯ã¨ã¹ãæ¯ã«1å¹´éã«è¨å®ããã #!/usr/bin/env python import sys if sys.hexversion < 0x02040000: print 'This script requires Python 2.4 or later.' print 'Currently run with version: %s' % sys.version sys.exit(1) import os import time import cgi import Cookie import random ## Initialize variables # _sid = None _uid = None ID_MAX_LENGTH = 15 ##
Web ã¢ããªã±ã¼ã·ã§ã³ãä½ãä¸ã§ã¯æ¬ ãããªã Cookieã æ¬ã³ã¼ãã¼ã§ã¯ Cookie ã®ä»çµã¿ã詳ãã説æããPerl ã¹ã¯ãªããã§ã®å®è£ æ¹æ³ãç°¡åã«è§£èª¬ãã¦ããã¾ãã ç®æ¬¡ Cookie ã¨ã¯ï¼ Cookie ã¨ã¯ããµã¼ãã¨ã®éä¿¡ã«ããã¦ç¹å®ã®æ å ±ãã¯ã©ã¤ã¢ã³ãï¼ãã©ã¦ã¶ã¼ï¼ã«ä¿æããããã®ã§ãã 主ã«ã¦ã¼ã¶ã¼ã»ãã·ã§ã³èå¥åãä¿åããããã«ä½¿ããããã¨ãå¤ãã§ãããã ãã®ä»çµã¿ã«ããããã°ã¤ã³ã¨ããä»çµã¿ãä½ã£ãããããªãåãã«ãã¼ã½ãã©ã¤ãºãããã³ã³ãã³ãã åºåã表示ãããªã©ï½ä»çµã¿ãå®ç¾ã§ããããã«ãªãã¾ãã Cookie ã使ããã¨ã«ãã£ã¦å¤å½©ãªæ©è½ãå®ç¾ãããã¨ãã§ãã¾ãã®ã§ã CGI ãä½æããã«ããã£ã¦ã¯é常ã«ä¾¿å©ãªæ©è½ã§ãã Cookie 㯠Netscape Communications Corporation ã PERSISTENT CLIENT STA
http://mm.apache.or.jp/pipermail/apache-users/2003-November/003529.html ããã®ã¹ã¬ããããã©ã http://mm.apache.or.jp/pipermail/apache-users/2003-November/003531.html ãçã print "Content-Type: text/html\n"; print "Content-Length: 6\n\ntest.\n"; ã¨ãContent-Length ãå ããã¨ãã¨ãããã表示ãããã½ã åã®æ¥ / 次ã®æ¥ / ææ° / 2004-04 2013 : 01 02 03 04 05 06 07 08 09 10 11 12 2012 : 01 02 03 04 05 06 07 08 09 10 11 12 2011 : 01 02 03 04 0
Content-Length ãããã®ã»ãã«ã ãåããã»ã¹ã§ STDOUT ã close ãã¦ã¯ãããªãã ããã ã(親ããã»ã¹ã¯ close ãã¦ãåä½ã«éãã¯ãªã) å ´åã«ãã£ã¦ã¯ãä¸è¨ã® KeepAlive ãç¡å¹ã«ããå¿ è¦ãããã
åºæ¬çã«ã¯ã»ãã·ã§ã³ç³»ã¢ã¸ã¥ã¼ã«ã®å½¹å²ã¯ãç¹å®ã®ãã¼ï¼ã»ãã·ã§ã³IDã«ç´ä»ãã¦ããã¼ã¿ãä¿åããããèªã¿è¾¼ãã ãã¨ãã£ããã¨ã§ãã ã»ãã·ã§ã³IDã®å渡ãã¯CGIå´ã§ããå¿ è¦ãããã¾ãã ã»ãã·ã§ã³IDã®å渡ãã¨ãã¦ã¯ããã¹ã«å«ããæ¹æ³ãCGIãã©ã¡ã¼ã¿ã«å«ããæ¹æ³ãCookieã«ä¿æãããæ¹æ³ãããã¾ããããã®å æå¾ã®Cookieã«ä¿æãããæ¹æ³ã«ã¤ãã¦ã§ãã CGIã¢ã¸ã¥ã¼ã«ã¨CGI::Sessionã¢ã¸ã¥ã¼ã«ãçµåããã¦ä½¿ç¨ããå ´åãCookieã使ç¨ããã»ãã·ã§ã³IDã®å渡ããç¹ã«æèããã«è¡ããããã«ãªã£ã¦ãã¾ãã ãªãã¸ã§ã¯ãçæã§ã¯ã次ã®ããã«CGI::Sessionã®ã³ã³ã¹ãã©ã¯ã¿ã®ç¬¬äºå¼æ°ã«ãã»ãã·ã§ã³IDã®ä»£ããã«CGIãªãã¸ã§ã¯ãã渡ãã¾ãã ãã©ã¤ããã·ãªã¢ã©ã¤ã¶ãªã©ã®ãã¼ã¿ã½ã¼ã¹åï¼ç¬¬ä¸å¼æ°ï¼ãããã³ãªãã·ã§ã³ã®æå®ï¼ç¬¬ä¸å¼æ°ï¼ã¯ä»»æã®ãã®ãæå®ãã¦æ§ãã¾ããã
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}