- 2006-11-23 (木) 0:00
- Life
大量のユニークIDが必要が必要になったときに。RFC 4122で定義されたUUIDを返すCGI。単にPython2.5のuuidモジュールを使っているだけでね。uuid.uuid4()の戻り値です。これでダブらないフシギ。
受け取るパラメータは、count=件数のみ。countは最大1000まで。
戻りは改行で区切られたテキスト。
例)
ローカル環境で動かせばなんてことないけれど、何かあったときのバックアップ用にでも。
#!/usr/bin/env python2.5
import cgi,uuid
__MAX_COUNT=1000
print "Content-type: text/plain\n"
try:
form = cgi.FieldStorage()
try:
count = int(form.getfirst("count",1))
if count>__MAX_COUNT: count=__MAX_COUNT
except:
count = 1
for i in range(count): print uuid.uuid4()
except Exception,msg:
print "error occured"
- Newer: 全国郵便番号一覧ver.6.11a
- Older: バーコード生成器
Comments:0
Trackbacks:0
- Trackback URL for this entry
- http://www.fabrice.co.jp/blog/archives/404/trackback
- Listed below are links to weblogs that reference
- uuidを取得するCGI from Fabrice Co. weblog
RSS
Twitter