Debugging CGI python

给你一囗甜甜゛ 提交于 2019-12-10 18:18:04

问题


Is there any easy way to debug cgi python programs apart from looking at the log file each time the browser generates an error?


回答1:


You can use the cgitb module. It's as simple as

import cgitb
cgitb.enable()

It doesn't always work (e.g. it won't help you for permission errors, or certain other kinds of errors), but when it does it's quite helpful!




回答2:


You could capture (or form by hand) the data and env variables which the CGI script receives, then plainly run the script under your favorite debugger and feed the data to it.

In order to capture the incoming data you can just dump it from the script in CGI mode to some log file, then re-use under debugger in standalone mode.



来源:https://stackoverflow.com/questions/7956696/debugging-cgi-python

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