大家好,我正在嘗試創建一個非常簡單的python CGI腳本,它接受表單數據並將其放入COOKIE中。這是我的代碼。簡單的python CGI cookie腳本,從表單獲取數據
#!/usr/bin/python
print "Content-type: text/html"
print
import Cookie, cgi, os, cgitb, smtplib, sys
cgitb.enable()
form = cgi.FieldStorage()
ID = form.getvalue('ID')
name = form.getvalue('name')
telephone = form.getvalue('telephone')
email = form.getvalue('email')
manager = form.getvalue('manager')
def set_clientCookie(ID, name, telephone, email, manager):
#create object
myCookie = Cookie.SmartCookie()
#Assign value
myCookie['ID'] = ID
myCookie['Name'] = name
myCookie['Tele'] = telephone
myCookie['Email'] = email
myCookie['Manager'] = manager
#Send back to client
print "Content-type: text/html"
print
print myCookie, "\n\n"
set_clientCookie(ID, name, telephone, email, manager)
正如你可以看到它是非常基本的,但我收到在日誌中「腳本頭錯誤過早結束。