我想從我的lighttpd服務器運行一個簡單的Python腳本。 HTML代碼是:從lighttpd運行python腳本 - Firefox要求保存文件
<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頁面,然後我點擊提交查詢? Firefox詢問「你已經選擇從本地主機打開cgi101.py」並詢問Firefox應該如何處理這個文件以及我是否想保存它。它不應該只是在Firefox中打開並運行Python腳本,而不是要求我保存Python腳本嗎?