在 app.yaml 文件中混合静态和动态端点
我正在尝试描述我的 App Engine 应用程序中的端点,但对于混合静态和动态内容的目录结构遇到困难。但我的 yaml 规则相互冲突。在我更改目录结构之前,有人有建议吗?
目标是创建一个包含文档(静态 html 文件)和实现的目录。
/api
- /v1
- getitdone.py
- doc.html
- index.html
我认为我应该对我的应用程序 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
但这会导致动态端点失败。我假设 static_dir
引用正在破坏它。如何在不描述每个脚本和静态文件引用的情况下执行此操作(我有比此处列出的更多的脚本和静态文件引用)?
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)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
其原因是您将
/api/
标记为静态目录,因此您的脚本将作为静态文件上传,这使得 App Engine 运行时无法访问它们。最简单的解决方案是将动态代码和静态资源放在应用程序目录层次结构的不同部分,并使用 app.yaml 将它们映射到所需的 URL 结构。
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.