1

I want to read a INI file from python, and I came up with the following script:

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)

From outside I just need to read:
xxx.appspot.com/map?location=mylocation&street=mystreet
And I double checked the INI file is uploaded and available:
xxx.appspot.com/Map.ini
It works just fine locally, but I get an error when deploying.
I've seen mentions of url fetch, but all examples I could find were the other way around
Any idea?

4

1 に答える 1

0

ファイルが URL 経由で利用できる場合、ほぼ確実に静的としてマークされています。AppEngine の制限の 1 つは、静的ファイルをコードから読み取れないことです。static 宣言を削除することで修正できるはずです。

これに関する詳細については、Read a file on App Engine with Python? を参照してください。

于 2012-07-05T09:14:54.890 に答える