Urllib错误500在本地运行

时间:2012-07-05 08:57:19

标签: python google-app-engine python-2.7

我想从python中读取一个INI文件,我想出了以下脚本:

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/map?location=mylocation&street=mystreet
我仔细检查了INI文件上传和可用:
xxx.appspot.com/Map.ini
它本地工作得很好,但部署时出错。
我已经看过提到网址了,但我能找到的所有例子都是另一种方式 有什么想法吗?

1 个答案:

答案 0 :(得分:0)

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

Read a file on App Engine with Python?

处加载了有关此内容的更多信息