0

So, I'm trying to host a website on the google cloud app engine, but css and other static files are not showing up. Here is the relevant directory structure:

myapp
  -app.yaml
  -manage.py
  subapp
    -apps.py
    -models.py
    -urls.py
    -views.py
    static
      -style.css

And the relevant portion of app.yaml:

runtime: python
env: flex 
api_version: 1
threadsafe: yes

handlers:
- url: /static
  static_dir: static
- url: .*
  script: myapp.wsgi.application

I would expect that when I go to https://myapp.appspot.com/static/style.css, they see the style.css file, but instead I get the 404 page not found error, and I see that gcloud compares the 'static/style.css' against the list of urls found in urls.py instead of the static directory specified in app.yaml.

What could be going wrong?

Everyone_Else
  • 3,206
  • 4
  • 32
  • 55
  • Possible duplicate of [How can I use bucket storage to serve static files on google flex/app engine environment?](http://stackoverflow.com/questions/41631414/how-can-i-use-bucket-storage-to-serve-static-files-on-google-flex-app-engine-env) – Dan Cornilescu Apr 09 '17 at 02:41
  • I suspect that your project root is set to `myapp` whereas the `static` is one directory below. Have you tried `static_dir: subapp/static` ? – karthikr Apr 09 '17 at 03:24

2 Answers2

1

Sadly, static handlers do not work on the flexible environment. You should just serve your CSS the way you normally would from your python application.

Justin Beckwith
  • 7,686
  • 1
  • 33
  • 55
0

You can try this in your app.yaml

handlers:
- url: /static/style.css
  static_files: static/style.css
  upload: static/style.css
amarnath
  • 785
  • 3
  • 19
  • 23