lighttpd サーバーから単純な Python スクリプトを実行しようとしています。HTML コードは次のとおりです。
<html>
<title>Interactive page</title>
<body>
<form method=POST action="cgi-bin/cgi101.py">
<P><B>Entery your name: </B>
<P><input type=text name=user>
<P><input type=submit>
</form>
</body>
</html>
私のPythonスクリプトは次のとおりです。
#!/usr/bin/python
import cgi
form = cgi.FieldStorage()
print('Content type:text/html \n')
print('<title>Reply Page</title>')
if not 'user' in form:
print('<h1>who are you</h1>')
else:
print(cgi.escape(form['user'].value))
私の質問は、HTML ページを読み込んで [Submit Query] をクリックできますか? Firefox は、localhost から「cgi101.py を開くことを選択しました」と尋ね、Firefox がこのファイルをどうするべきか、そしてそれを保存するかどうかを尋ねています。Python スクリプトを保存するように要求するのではなく、Firefox で開いて Python スクリプトを実行するだけでよいのではないでしょうか?