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?

lemo
  • 13
  • 3

1 Answers1

0

If your file is available via the URL it's almost certainly marked as static. One of the limitations of AppEngine is that static files cannot be read from code. You should be able to fix it by removing the static declaration.

There's loads more information about this at Read a file on App Engine with Python?

Community
  • 1
  • 1
Maria Zverina
  • 10,863
  • 3
  • 44
  • 61
  • Yup it works thanks! I didn't really get the point before that it would be uploaded anyway when it appears in the code. Totally removed it from the app.yaml :] – lemo Jul 05 '12 at 10:44