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 ##
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く