3

I'm facing issues with app.yaml settings of my Python App Engine web application. Somehow except index.html rest of the static files (javascript, CSS and HTML) which I have in my application are not getting deployed to the app engine. I have tried variety of combinations of static_files and upload elements under script in app.yaml. Though some of them work on local dev app server, they do not work when deployed on app engine via gcloud app deploy. Logs produced by the gcloud do not show any errors. They show DEBUG messages like "Skipping upload of [...]" for all my static files.

Directory structure of the application (it's an AngularJS application) is as follows:

<APP ROOT>
├── app.yaml
├── my_scripts
│   ├── foo.py
│   └── ...
├── index.html
├── mainapp.py
└── web
    ├── assets
    │   ├── css
    │   │   ├── bootstrap.min.css
    │   │   ├── bootstrap-theme.min.css
    │   │   ├── ....
    │   │   └── ....
    │   └── js
    │       ├── app
    │       │   ├── app.js
    │       │   └── ....
    │       └── lib
    │           └── ...
    └── partials
        ├── login.html
        └── ...

Following is the app.yml file for my application.

runtime: python27
api_version: 1
threadsafe: true

handlers:

- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: /(user|tasks)/.*
  script: mainapp.app

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

- url: /web
  static_files: web\/[^\n]*
  upload: web\/[^\n]*

- url: /web
  static_dir: web

Any pointers to help me fix this issue will be greatly appreciated.

b.sodhi
  • 93
  • 2
  • 7
  • Take a look at http://stackoverflow.com/questions/33447890/static-files-are-missing/33448239#33448239. See if addressing that problem helps with the static files being skipped during deployment. BTW - is there a reason for skipping them displayed anywhere? – Dan Cornilescu Mar 17 '17 at 16:58

2 Answers2

1

You have the change the routing order. That is, /web should come just before to the / handler so that the GAE routing will look for /web at first and then it goes for / (note down the order top to bottom). If you define / before /web, it always shows the index.html file since / will also match /web.

handlers:

- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: /(user|tasks)/.*
  script: mainapp.app

- url: /web
  static_dir: web

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

And also I hope you haven't add ^web to the skip_files section in app.yaml

Avinash Raj
  • 160,498
  • 22
  • 182
  • 229
1

The following handler configuration has worked for me:

- url: /(user|tasks)/.*
  script: mainapp.app

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

- url: /web
  static_files: web/(.*)/(.*)/(.*)/(.*)
  upload: web/(.*)/(.*)/(.*)/(.*)

- url: /web
  static_dir: web
b.sodhi
  • 93
  • 2
  • 7
  • So you're saying that both `/web/assets/css/bootstrap.min.css` and `/web/assets/js/app/app.js` are uploaded with this config? – Dan Cornilescu Mar 21 '17 at 20:29