2012-07-05 28 views
1

我想读从Python中的INI文件,和我下面的脚本上来:的urllib错误500个本地工作

import webapp2 
import urllib 
import ConfigParser 

class MainPage(webapp2.RequestHandler): 
    def get(self): 
    getstreet = self.request.get('street') 
    getlocation = self.request.get('location') 
    self.response.headers['Content-Type'] = 'text/plain' 
    map = ConfigParser.RawConfigParser() 
    map.read('Map.ini') 
    coords = map.get(getlocation, getstreet) 
    self.response.out.write(coords) 

app = webapp2.WSGIApplication([('/map', MainPage)], 
           debug=True) 

从外面我只需要阅读:
xxx.appspot.com/地图位置= mylocation &街道= mystreet
我仔细检查了该INI文件上传和可用:
xxx.appspot.com/Map.ini
它本地工作得很好,但在部署时,我得到一个错误。
我见过提到url提取,但我可以找到的所有例子都是相反的
任何想法?

回答

0

如果您的文件通过URL可用,它几乎肯定会被标记为静态。 AppEngine的一个限制是无法从代码中读取静态文件。您应该可以通过删除静态声明来修复它。

有负载这个在Read a file on App Engine with Python?

+0

更多信息,没错它工作的感谢!我之前并没有真正明白这一点,无论如何,它出现在代码中时都会被上传。完全删除它从app.yaml:] – lemo 2012-07-05 10:44:18

+0

@ user1503382随时upvote并接受答案:) – 2012-07-05 11:29:49