Jordan
Jordan

Reputation: 1619

Golang Appengine - How to serve a static file from root url

I tried to deploy my go app to appengine and it complains that my root url isn't handled on the server. My app.yml file is set up to serve index.html when the root url is hit. It seems to work locally. Is there something wrong with this approach? Here's my yaml file. Thanks!

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/

Upvotes: 1

Views: 556

Answers (1)

Jeffrey Godwyll
Jeffrey Godwyll

Reputation: 3893

The handler is not seeing your index.html in your uploads directory that corresponds with the given url and static_files. Use this instead:

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

If you have other static files you want to make available under the uploads route I'll suggest you separate them to be:

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

- url: /uploads
  static_dir: js_app/uploads/

Upvotes: 1

Related Questions