部署我的第一个应用引擎应用程序后,我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: /
Run Code Online (Sandbox Code Playgroud)
我可以毫无问题地访问任何其他目录和位于这些目录中的文件。此外,如果您查看index条目下方,该elements.html路线也有效。
我注意到在其他项目中人们正在定义一个/static目录。这是要求吗?我的本地环境为这个应用程序提供服务,没有任何问题。
命名目录static不是必需的。我这样做是因为它使布局的重要性显而易见(至少对我而言)。
这app.yaml是我的一个应用程序中的一个片段,它有一个静态主页和静态资产。
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
Run Code Online (Sandbox Code Playgroud)
顺序很重要,因为使用 of/.+而不是/.*后者,请求/将被路由到main.app
编辑添加:具有静态的 url 映射对于favicon.ico防止请求被路由到您的应用程序很有用,因为这会导致 App Engine 在不需要实例时启动一个实例。
| 归档时间: |
|
| 查看次数: |
2140 次 |
| 最近记录: |