我有一张表格如下:
<form action = "get.py" method = "get">
First Name: <input type = "text" name = "first_name"> <br />
Last Name: <input type = "text" name = "last_name" />
<input type = "submit" value = "Submit" />
</form>
我试图通过python cgi传递值,(centos + apache + cgi)
#!/usr/bin/python
# Import modules for CGI handling
import cgi, cgitb
# Create instance of FieldStorage
form = cgi.FieldStorage()
# Get data from fields
tt = form.getvalue('first_name')
cc = form.getvalue('last_name')
import sqlite3
conn = sqlite3.connect('personal.db')
c = conn.cursor()
sql = "INSERT INTO PQ VALUES ('%s', '%s', Datetime('now'), '0')" % (tt, cc)
c.execute(sql)
c.close()
db如下:
sqlite> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE PQ (Title TEXT, Description TEXT, Time TEXT, Deleted TEXT);
INSERT INTO PQ VALUES('biochem','how to do learning path','2018-05-16 03:55:54','')
COMMIT;
sqlite> .q
当我尝试提交数据时,cgi会返回错误,如:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
我该怎么做才能解决这个问题?是否缺少任何配置?