Created
March 23, 2021 18:33
-
-
Save davidwtbuxton/b083fb181a973ee43637a900fc36866f to your computer and use it in GitHub Desktop.
Example of App Engine static website with Python redirect handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runtime: python37 | |
handlers: | |
# Redirect / and /my-example-project to /my-example-project/. Requires Python. | |
- url: /(my-example-project)?$ | |
script: auto | |
secure: always | |
# The static assets are collected in a "dist" folder. | |
- url: /(.*/)?$ | |
static_files: dist/\1index.html | |
upload: dist/.*index.html | |
secure: always | |
http_headers: | |
Strict-Transport-Security: "max-age=2592000; includeSubdomains" | |
X-Content-Type-Options: "nosniff" | |
X-Frame-Options: "DENY" | |
X-XSS-Protection: "1; mode=block" | |
Content-Security-Policy: >- | |
base-uri 'none'; | |
object-src 'none'; | |
script-src 'self' | |
*.gstatic.com | |
*.googletagmanager.com | |
https://www.google-analytics.com/analytics.js; | |
- url: / | |
static_dir: dist | |
secure: always | |
http_headers: | |
Strict-Transport-Security: "max-age=2592000; includeSubdomains" | |
X-Content-Type-Options: "nosniff" | |
X-Frame-Options: "DENY" | |
X-XSS-Protection: "1; mode=block" | |
Content-Security-Policy: >- | |
base-uri 'none'; | |
object-src 'none'; | |
script-src 'self' | |
*.gstatic.com | |
*.googletagmanager.com | |
https://www.google-analytics.com/analytics.js; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import flask | |
app = flask.Flask(__name__) | |
@app.route('/') | |
@app.route('/my-example-project') | |
def redirect_home(): | |
return flask.redirect('/my-example-project/') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flask==1.1.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment