Tag: 网站服务

最好的方法来创build一个简单的Python Web服务

我一直在使用python多年,但是我对python web编程有一点经验。 我想创build一个非常简单的Web服务,公开现有的Python脚本中的一些function用于我的公司内部。 它可能会在csv中返回结果。 什么是最快捷的方法来获取? 如果它影响到你的build议,我可能会在下面添加更多的function。

您如何从(非Web)Python客户端访问经过身份validation的Google App Engine服务?

我有一个Google App Engine应用程序 – http://mylovelyapp.appspot.com/它有一个页面 – mylovelypage 目前,页面只是self.response.out.write('OK') 如果我在我的电脑上运行以下Python: import urllib2 f = urllib2.urlopen("http://mylovelyapp.appspot.com/mylovelypage") s = f.read() print s f.close() 它打印“确定” 问题是如果我添加login:required在应用程序的yaml这个页面 那么这会打印出Google帐户login页面的HTML 我已经尝试了“正常”的身份validation方法。 例如 passman = urllib2.HTTPPasswordMgrWithDefaultRealm() auth_handler = urllib2.HTTPBasicAuthHandler() auth_handler.add_password(None, uri='http://mylovelyapp.appspot.com/mylovelypage', user='billy.bob@gmail.com', passwd='billybobspasswd') opener = urllib2.build_opener(auth_handler) urllib2.install_opener(opener) 但它没有区别 – 我仍然得到login页面的HTML回来。 我已经尝试了Google的ClientLogin auth API ,但是我无法使它工作。 h = httplib2.Http() auth_uri = 'https://www.google.com/accounts/ClientLogin' headers = {'Content-Type': […]