Golang Appengine - 如何从根URL提供静态文件

时间:2015-07-11 21:34:40

标签: google-app-engine go

我尝试将我的go应用程序部署到appengine并且它抱怨我的根URL未在服务器上处理。我的app.yml文件设置为在根网址被命中时为index.html提供服务。它似乎在本地工作。这种方法有问题吗?这是我的yaml文件。谢谢!

application: myapp-go
version: 2
runtime: go
api_version: go1

handlers:
- url: /
  static_files: js_app/index.html
  upload: js_app/uploads/.*

- url: /api/.*
  script: _go_app

- url: /javascripts
  static_dir: js_app/javascripts/

- url: /stylesheets
  static_dir: js_app/stylesheets/

- url: /templates
  static_dir: js_app/templates/

- url: /images
  static_dir: js_app/images/

1 个答案:

答案 0 :(得分:1)

处理程序未在您的index.html目录中看到与给定uploadsurl对应的static_files。请改用:

handlers:
- url: /
  static_files: js_app/index.html
  upload: js_app/index.html

如果您想要在uploads路线下提供其他静态文件,我建议您将它们分开:

handlers:
- url: /
  static_files: js_app/index.html
  upload: js_app/index.html

- url: /uploads
  static_dir: js_app/uploads/