2009年8月22日土曜日

CGIHTTPServer

サーバを起動

import CGIHTTPServer
CGIHTTPServer.test()


起動したフォルダにcgi-binフォルダを用意

そこにindex.pyというファイルを作って中身を適当に書く


print "<html>"
print "<head><title>test</title></head>"
print "<body>test</body>"
print "</html>"


http://localhost:8000/cgi-bin/index.pyにアクセス
・firefoxではなにも表示されない
・ie8では表示される

firefoxで表示されるようにするには、先頭に

print "Content-type: text/html\n"

が必要だった。

0 件のコメント: