Returning Output of Python CGI MySQL Script

时光怂恿深爱的人放手 提交于 2019-12-02 00:08:58

First, as per the CGI tutorial you link, you need to output the content type you are working with:

print "Content-type: text/plain\r\n\r\n",

If you don't at least have the newlines in there, HTTP clients will think your content is supposed to be part of the headers and get confused, they will probably assume the document you asked for is empty.

Next, you need a CGI server. Python comes with one. Place your script in a subdirectory called cgi-bin and run this command (from the parent directory):

python -m CGIHTTPServer

The url to call will look something like this:

curl http://localhost:8000/cgi-bin/cgitest.py
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!