A zero configuration, localization-aware static server that supports redirects designed to be used with Google App Engine.
Many static websites require limited dynamic functionality such as:
- Vanity URL redirects
- Trailing slash normalization
- Localization (via redirects or rewriting responses)
This utility provides the above limited functionality in a zero-configuration manner, compatible with the podspec.yaml
syntax for Grow websites and an additional redirect configuration file.
- Create an
extensions.txt
file within your pod. - Add to the file:
git+git://github.com/grow/grow-ext-static-server
- Run
grow install
. - Add
requirements.txt
to the project root:
gunicorn
pyyaml
webapp2==3.0.0b1
- Add an
app.yaml
file to the project root:
# app.yaml
runtime: python37
entrypoint: gunicorn -b :$PORT -w 2 extensions.grow_static_server.main:app
handlers:
- url: (.*)
script: auto
secure: always
- Add a
.gcloudignore
file to the project root:
*
!/build/**
!/extensions/**
!/podspec.yaml
!/redirects.py
!/redirects.yaml
!/requirements.txt
!.
- Optionally add redirects, via
redirects.yaml
in the project root:
# redirects.yaml
redirects:
- ['/vanity-url', '/some-much-longer-destination-url']
- ['/test', 'https://example.com/']
- ['/test/:foo', 'https://example.com/$foo']
settings:
custom_404_page: 404.html # Path in 'build/' folder for custom 404 page.
rewrite_localized_content: true # Either true (default) or false.
trailing_slash_behavior: add # Either 'add' (default) or 'remove'.
- Deploy the application. See Makefile for example deployment commands.