Write to a file in the Google App Engine Development serverPosted: Last updated:
The App Engine development server tries to mimic the real environment by making it forbidden to write to the filesystem. However, for certain things you might want to do that anyway, for example to log to a file. In that case you can use this code snippet to enable writing to the filesystem:
if os.environ.get('SERVER_SOFTWARE','').startswith('Dev'): from google.appengine.tools.devappserver2.python.stubs import FakeFile FakeFile.ALLOWED_MODES = frozenset(['a','r', 'w', 'rb', 'U', 'rU'])
Update 18.12.2015: Updated to use the correct import path for the latest version of the SDK. Thanks to Dan Lester.