在app.yaml文件中混合静态和动态端点 [英] Mixing static and dynamic endpoints in app.yaml file

查看:103
本文介绍了在app.yaml文件中混合静态和动态端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的App Engine应用中描述端点,并且难以混合静态和动态内容的目录结构。但是我的yaml规则彼此冲突。在改变我的目录结构之前,有没有人有推荐?



目标是创建一个包含文档(静态HTML文件)和实现的目录。

  / api 
- / v1
- getitdone.py
- doc.html
- index.html

我认为我应该用我的应用程序yaml ...

   -  url:/ api / v1 / getitdone 
脚本:api / v1 / getitdone.py

- url:/ api /
static_files:api / index.html
上传:api / index.html

- url:/ api
static_dir:api

但是这会导致动态端点失败。我假设 static_dir 引用正在破坏它。如何在不描述每个脚本和静态文件引用的情况下执行此操作(我有更多的内容在这里列出)?

解决方案

原因在于,您将 / api / 标记为静态目录,因此您的脚本将作为静态文件上传,这使得它们无法访问App Engine运行时。

最简单的解决方案是将动态代码和静态资源放在应用程序目录的不同部分,并使用app.yaml将它们映射到所需的URL结构。

I'm trying to describe endpoints in my App Engine app and am having difficulty for directory structures that mix static and dynamic content. But my yaml rules are conflicting with one another. Before I change my directory structure, does anyone have a recommendation?

The goal is to create a directory that contains both documentation (static html files) and implementations.

/api
  - /v1
    - getitdone.py
  - doc.html
  - index.html

What I think I should be doing with my application yaml...

- url: /api/v1/getitdone
  script: api/v1/getitdone.py

- url: /api/
  static_files: api/index.html
  upload: api/index.html  

- url: /api
  static_dir: api

But this causes the dynamic endpoints to fail. I'm assuming the static_dir reference is breaking it. How can I do this without describing every script and static file reference (I have many more than are listed here)?

解决方案

The cause of this is that you're marking /api/ as a static directory, so your scripts are getting uploaded as static files, which makes them inaccessible to the App Engine runtime.

The easiest solution would be to put your dynamic code and your static resources in different parts of your app's directory heirarchy, and use app.yaml to map them into the desired URL structure.

这篇关于在app.yaml文件中混合静态和动态端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆