【问题标题】:Urllib error 500 works locallyUrllib 错误 500 在本地工作
【发布时间】:2012-07-05 08:57:19
【问题描述】:

我想从 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
它在本地运行良好,但在部署时出现错误。
我见过提到 url fetch,但我能找到的所有例子都是相反的
有什么想法吗?

【问题讨论】:

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


    【解决方案1】:

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

    Read a file on App Engine with Python? 有更多关于此的信息

    【讨论】:

    • 是的,谢谢!在它出现在代码中时,我并没有真正明白它无论如何都会被上传。完全从 app.yaml 中删除它:]
    猜你喜欢
    • 2016-04-28
    • 1970-01-01
    • 2021-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-13
    • 2018-12-27
    相关资源
    最近更新 更多