google-app-engine - 未找到处理程序引用的静态文件 : index. html

标签 google-app-engine

部署我的第一个应用引擎应用程序后,我收到 Static file referenced by handler not found: index.html 作为日志中的错误。这是我的 yaml 文件:

application: section-14
version: v1
api_version: 1
runtime: python27
threadsafe: yes

handlers:
- url: /bower_components
  static_dir: bower_components
- url: /general
  static_dir: general
- url: /projects
  static_dir: projects
- url: /js
  static_dir: js
- url: /styles
  static_dir: styles
- url: /elements
  static_dir: elements
- url: /images
  static_dir: images

#here's the problem
- url: /
  static_files: index.html
  upload: /
#------------------

- url: /elements.html
  static_files: elements.html
  upload: /

我可以毫无问题地访问任何其他目录和位于这些目录中的文件。此外,如果您查看 index 条目下方,则 elements.html 路由也有效。

我注意到在其他项目中人们正在定义一个 /static 目录。这是要求吗?我的本地环境为这个应用程序提供服务,没有任何问题。

最佳答案

命名目录 static 不是必需的。我这样做是因为它使布局的重要性显而易见(至少对我而言)。

这是我的一个应用程序中的一个 app.yaml 片段,它有一个静态主页和静态 Assets 。

handlers:
- url: /style/
  static_dir: static/style
- url: /js/
  static_dir: static/js
- url: /favicon.ico
  static_files: static/favicon.ico
  upload: static/favicon.ico
  mime_type: image/x-icon
- url: /.+
  script: main.app
- url: /
  static_files: static/index.html
  upload: static/index.html

顺序很重要,因为使用 /.+ 而不是 /.* 对于后者,对 / 的请求将被路由到 main.app
编辑添加:具有静态 favicon.ico 的 url 映射对于防止请求被路由到您的应用程序很有用,因为这会导致 App Engine 在不需要实例时启动一个实例。

关于google-app-engine - 未找到处理程序引用的静态文件 : index. html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31482884/

相关文章:

google-app-engine - 用于自定义 SSL 设置的 App Engine 应用程序 ID

java - App Engine 是否自动生成 Long @id 在实体范围内是唯一的?

javascript - 是否可以通过来自非 appspot.com 域的 https 登录用户在 Google App Engine 上使用 Ajax?

python - Google App Engine URL Fetch 不适用于生产环境

java - 硬删除的对象仍然出现在 AppEngine 管理控制台中

eclipse - 无法完成安装 Google Plugin for eclipse

java - 使用 App Engine 自动缩放的 Firebase 身份验证

java - 如何在没有 appengine 的情况下使用 google-api-services-plus-v1

python - 在 Google App Engine 上模拟浏览器

google-app-engine - Google App Engine 路由和路径