相关代码
尝试1:
directory = os.path.dirname (__file__)
path = os.path.join (directory, 'json', 'gitkit-server-config.json')
gitkit_instance = gitkitclient.GitkitClient.FromConfigFile (path)企图2:
directory = os.path.dirname (__file__)
path = os.path.join (directory, 'gitkit-server-config.json')
gitkit_instance = gitkitclient.GitkitClient.FromConfigFile (path)在dev服务器和生产服务器上获得以下错误:(在两次尝试中都有类似的错误)
信息2014-08-29 14:34:21,621 module.py:642]默认:"GET /_ah/热身HTTP/1.1“500 -错误2014-08-29 09:04:26 540 wsgi.py:262] 回溯(最近一次调用): 文件"C:\Program (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py",第239行,在句柄中 处理程序= _config_handle.add_wsgi_middleware(self._LoadHandler()) 文件"C:\Program (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py",line 298,in _LoadHandler 处理程序,路径,err = LoadObject(self._handler) 文件"C:\Program (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py",第84行,在LoadObject中 obj =__import__(路径) 文件"C:\gaurav\coding\python\myapp\myapp\main_v3.py",第107行,在gitkit_instance = gitkitclient.GitkitClient.FromConfigFile (路径)中 文件"C:\gaurav\coding\python\myapp\myapp\gitkitclient.py",第193行,在FromConfigFile中 json_data =simplejson.load(打开(配置)) 文件"C:\Program (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\stubs.py",第248行,init 引发IOError(errno.EACCES,“文件不可访问”,文件名) 'C:\gaurav\coding\python\myapp\myapp\json\gitkit-server-config.json‘:IOError: Errno 13文件不可访问 信息2014-08-29 14:34:26,591 module.py:642]默认:"GET /_ah/预热HTTP/1.1“500 -
相关片段app.yaml:
::
handlers:
# For Google Identity Toolkitv3 Oauth2
- url: /gitkit-server-config\.json
static_files: gitkit-server-config.json
upload: gitkit-server-config\.json
- url: /json
mime_type: application/json
static_dir: json
::文件("gitkit-server-config.json')被复制并保存在两个地方:
C:\\gaurav\\coding\\python\\myapp\\myapp\\gitkit-server-config.json
C:\\gaurav\\coding\\python\\myapp\\myapp\\json\\gitkit-server-config.json 当我将"http://www.myapp.com/gitkit-server-config.json"放到web浏览器中时,文件就会被下载。
我做错了什么?感谢你的帮助。
发布于 2014-08-29 14:24:31
如果必须使用Python读取文件,请不要在app.yaml中声明文件静态。创建非静态副本或更改app.yaml
更新:您可以为您的可读性中的静态目录配置‘app.yaml: true’:
- url: /static
static_dir: static
application_readable: true发布于 2014-08-29 12:03:44
所有路径都应该相对于您的app.yaml所处的位置。所以如果您的目录结构就像
| - myapp/
| | -app.yaml
| | - json/
| | - gitkit-server-config.json你可以试试:
path = os.path.join('json', 'gitkit-server-config.json')
gitkit_instance = gitkitclient.GitkitClient.FromConfigFile (path)https://stackoverflow.com/questions/25565224
复制相似问题