开发者

debugging python web service

开发者 https://www.devze.com 2023-01-29 14:45 出处:网络
I am using the instructions found here, to try to inspect the HTTP commands being sent to my webserver.

I am using the instructions found here, to try to inspect the HTTP commands being sent to my webserver.

However, I am not seeing the HTTP commands being printed on the console as 开发者_如何转开发suggested in the tutorial. Does anyone know how to display/debug the HTTP commands at the CLI?

I am running Python 2.6.5 on Linux Ubuntu


The tutorial information seems to be deprecated.

Correct way to debug with urllib2 nowadays is:

import urllib2
request = urllib2.Request('http://diveintomark.org/xml/atom.xml')
opener = urllib2.build_opener(urllib2.HTTPHandler(debuglevel=1))    
feeddata = opener.open(request).read()

Debugging with urllib works the old way though.

0

精彩评论

暂无评论...
验证码 换一张
取 消