I have a google app engine application and I am using python 27. I want my url when deployed to be applicationName.appspot.com/docs/ec-quickstart/index.html

How do I write my app.yaml file?

The code below loads my index.html file without the css.

  handlers:

  - url: /docs/ec-quickstart/index.html
  static_files: docs/ec-quickstart/index.html
  upload: docs/ec-quickstart/index.html

However, if I change my file to

  handlers:

  - url: /(.*)
  static_files: docs/ec-quickstart/\1
  upload: docs/ec-quickstart/(.*)

  - url: /docs/ec-quickstart/index.html
  static_files: docs/ec-quickstart/index.html
  upload: docs/ec-quickstart/index.html

Everything loads properly with the css for the url applicationName.appspot.com

I want the url to be mapped to applicationName.appspot.com/docs/ec-quickstart/index.html

2

There are 2 answers

0
Dan Cornilescu On BEST ANSWER

You need to specify rules for every piece you're going to serve and construct your html to reference them accordingly. Pay attention to the patterns as the 1st match will be used even if a more specific one follows below.

The 1st attempt doesn't specify where your .css file exists.

The 2nd attempt suggests your .css file is in the same directory with the index.html file and are both served using just the 1st rule (index.html matches as well, the 2nd rule is not actually used).

So you could use just one rule matching both file but modify the html to reference the css as /docs/ec-quickstart/blah.css:

  - url: /docs/ec-quickstart/(.*)
  static_files: docs/ec-quickstart/\1
  upload: docs/ec-quickstart/(.*)

Or still use 2 rules (and possibly more for other pieces but make sure the respective patterns don't match index.html) with no html modification:

  - url: /(.*\.css)$
  static_files: docs/ec-quickstart/\1
  upload: docs/ec-quickstart/(.*\.css)$

  - url: /docs/ec-quickstart/index.html
  static_files: docs/ec-quickstart/index.html
  upload: docs/ec-quickstart/index.html
0
Poorva Rane On

The answer suggested by Dan Cornilescu works perfectly. For anyone else out there who has the same problem, here's another approach which I figured out.

  handlers:

  - url: /docs/ec-quickstart
    static_dir: docs/ec-quickstart