IISPython

コンパネの「プログラムと機能」でWindowsの機能の有効化または無効化を選ぶ。
インターネットインフォメーションサービスをチェック。
また、その中のWorld Wide Webサービス、アプリケーション開発機能、CGIをチェックしOK。
「C:\inetpub\wwwroot\test」ディレクトリを作成し、test.pyを後述のように作成。
コンパネの管理ツールを開き、「インターネット インフォメーション サービス (IIS) マネージャー」を起動。
testフォルダをアプリケーションに変換。
testアプリケーションのハンドラーマッピングで、スクリプトマップの追加。
要求パスを「*.py」、実行可能ファイルを「python.exeのパス %s %s」、名前を「Python CGI」としOK。

def Rule(rule, size=16):
    a, d = [1], {7 - i:int(c == '1') for i, c in enumerate('{:8b}'.format(rule))}
    for i in range(size):
        print('%*s%s' % (size - i, '', ''.join('.#'[j] for j in a)))
        a = [d[sum(x * y for x, y in zip([4, 2, 1],
            ([0, 0] + a + [0, 0])[j:]))] for j in range(2 * i + 3)]

print('Status: 200 OK')
print('Content-type: text/html')
print()
print('<HTML><HEAD><TITLE>Python Sample CGI</TITLE></HEAD>')
print('<BODY>')
print('<H1>Rule 90</H1>')
print('<pre>')
Rule(90)
print('</pre>')
print('</BODY>')