【发布时间】:2017-02-24 22:39:01
【问题描述】:
我已经使用 Swagger 编辑器创建了一个 REST API,并且我请求了 Python Flask 的服务器代码下载。我正在尝试将其部署到 Google Cloud Platform(我认为这是最新名称?还是仍然是 GAE?)但我需要填补一些空白。
我知道 Swagger 代码有效,因为我已在本地部署它,没有任何问题。但是,它直接使用 connexion 库而不是 Flask。
对于如何将 GCP 的 app.yaml 文件和正确的入口点合并到生成的代码中,我很迷茫。此外,我知道生成的代码声明了它自己的应用服务器,我认为你不需要为 GCP 做。 这是我当前的 app.yaml
application: some-app-name
version: 1
runtime: python27
api_version: 1
threadsafe: yes
entrypoint: python app.py
libraries:
- name: connexion
version: "latest"
这是我的 app.py
import connexion
if __name__ == '__main__':
app = connexion.App(__name__, specification_dir='./swagger/')
app.add_api('swagger.yaml', arguments={'title': 'this is my API'})
app.run(port=8080)
我现在遇到的主要错误是
google.appengine.api.yaml_errors.EventError: the library "connexion" is not supported
我有一种感觉,这是因为我在 app.py 中声明应用服务器的方式 - 可能不需要它。我将如何修改此文件以仍然使用我的 Swagger 代码但在 GCP 上运行?
【问题讨论】:
-
坚持 GAE,GCP 包括 GAE,但也包括其他 Google 产品,其中一些与 GAE 完全无关:cloud.google.com/products
标签: python google-app-engine flask swagger google-cloud-platform