大量のユニーク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"