John Smith
John Smith

Reputation: 333

Problem with accessing static files when deploying Django API using Google App Engine

I have schema.yml documentation in the static folder in my project and during development everything seems to be working properly however after deployment to the App Engine I get the error Not Found /static/schema.yml. My configuration looks in the way shown below. Do you have any ideas what can be the cause of the problem?

settings.py:

PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATICFILES_DIRS = (
  os.path.join(BASE_DIR, 'templates'),
)
STATIC_URL = '/static/'

app.yaml:

runtime: custom
env: flex
entrypoint: gunicorn -b :$PORT mysite.wsgi
service: mysite-service

handlers:
- url: /static/
  static_dir: static

Upvotes: 0

Views: 205

Answers (1)

Samuel Romero
Samuel Romero

Reputation: 1253

Google App Engine Flex for custom environments ignores the handlers section. There are no issues if you add this section to your “app.yaml” but are not used by the environment. The handlers section is for Google App Engine Standard. So, that is the reason why in the App Engine Standard environment works but not in App Engine flex. The only language that supports handlers is java and you can find documentation that says that it is possible to do it.

However, in order to serve static files, you can take a look at this doc where it includes the necessary steps to configure static files in App Engine Flex.

Upvotes: 1

Related Questions