简体   繁体   English

app.yaml /项目文件结构适用于app引擎localhost调试器,但不适用于谷歌应用引擎服务器

[英]app.yaml / project file structure works on app engine localhost debugger but not on google app engine server

This issue is probably a result of my limited understanding of project structures in Python and app engine as well as my limited understanding of the app.yaml file. 这个问题可能是由于我对Python和app引擎中项目结构的理解有限,以及我对app.yaml文件的理解有限。

I have a python 2.7 project who's file structure looks like this: 我有一个python 2.7项目,其文件结构如下所示:

Project_name
 > src
   app.yaml
   > python
     __init__.py
     > package_folder1
       __init__.py
       package1_file.py
     > package_folder2
       __init__.py

My app.yaml file has this in it: 我的app.yaml文件中有这个:

- url: /package1/resource1
  script: package_folder1.package1_file1.py
  secure: always

This works fine when debugging on localhost using app engine's simulator, but on the server, I am getting this warning (which in this case is an error because the script is not being served) when I try to access the resource /package1/resource1 : 这在使用app引擎的模拟器在localhost上调试时工作正常,但在服务器上,当我尝试访问资源/package1/resource1时,我收到此警告(在这种情况下是一个错误,因为脚本没有被提供):

File referenced by handler not found: python.package_folder1.package1_file1.py

I also tried changing the line in the app.yaml file to this script: package_folder1.package1_file1.py and still got the same error. 我还尝试将app.yaml文件中的行更改为此script: package_folder1.package1_file1.py并仍然出现相同的错误。

Any ideas? 有任何想法吗? Thanks! 谢谢!

What runtime are you using python 2.5 or python 2.7? 您使用python 2.5或python 2.7的运行时是什么时候? There are some differences when using one or the other. 使用其中一个时存在一些差异。 Also, where in your project structure are you storing the app.yaml file? 此外,您的项目结构中存储app.yaml文件的位置?

For python 2.5 you specify the actual python script, but for python 2.7 you specify the WSGI application. 对于python 2.5,您指定实际的python脚本,但是对于python 2.7,您指定了WSGI应用程序。 See https://developers.google.com/appengine/docs/python/config/appconfig#Script_Handlers for more details. 有关详细信息,请参阅https://developers.google.com/appengine/docs/python/config/appconfig#Script_Handlers

The runtime is defined in the app.yaml file with the key runtime. 运行时在app.yaml文件中使用密钥运行时定义。

runtime: python   #python 2.5
runtime: python27 #python 2.7

Is the python folder the entire python runtime? python文件夹是整个python运行时吗? If so, you should not be including that. 如果是这样,你不应该包括那个。

Project_name
> src
  app.yaml
  > package_folder1
    __init__.py
    package1_file.py
  > package_folder2
    __init__.py

Use slashes instead of periods to specify the script in the app.yaml file: 使用斜杠而不是句点来指定app.yaml文件中的脚本:

script: package_folder1/package1_file1.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为Google App Engine应用程序写入`app.yaml`文件? - How to write `app.yaml` file for Google App Engine app? Google App Engine | Python |的app.yaml - Google App Engine | Python | APP.YAML app.yaml文件:运行2个Python文件Google App Engine - app.yaml file: Running 2 Python Files Google App Engine Google App Engine 不为我在 app.yaml 中定义的入口点提供服务 - Google App Engine is not servig my defined entrypoint in app.yaml 如何使用应用工厂将 Flask 应用部署到 Google Cloud(App Engine),以及如何编写 app.yaml 文件? - How to deploy a Flask app to Google Cloud (App Engine) with an application factory, and how to write the app.yaml file? Google应用程序引擎python cron:app.yaml文件中的testcron.py在做什么? - Google app engine python cron: What is the testcron.py doing in the app.yaml file? 如何使用App Engine app.yaml文件中定义的路由从Google Cloud Storage提供内容? - How to serve content from Google Cloud Storage with routes defined in App Engine app.yaml file? 要在Google App Engine上托管静态(HTML)网站,app.yaml文件中应包含哪些内容? - To host a static (HTML) website on Google App Engine, what should be in the app.yaml file? Google App Engine的项目结构 - Project structure for Google App Engine Python App Engine:使用app.yaml来控制url处理程序 - Python App Engine : use app.yaml to control url handler
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM