Created
July 21, 2025 09:08
-
-
Save davidwtbuxton/46a511b6a7e64df5536922c7e4d35dca to your computer and use it in GitHub Desktop.
App Engine standard + Python redirect app
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: python313 | |
handlers: | |
- url: /.* | |
script: auto | |
secure: always | |
automatic_scaling: | |
max_instances: 1 |
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 http | |
def app(environ, start_response): | |
"""Respond with a page or redirect or something for any request.""" | |
status = http.HTTPStatus.FOUND | |
response_status = f"{status.value} {status.phrase}" | |
headers = [ | |
("Content-type", "text/html; charset=utf-8"), | |
("Location", "https://www.google.com/"), | |
] | |
start_response(response_status, headers) | |
return [b""] | |
if __name__ == "__main__": | |
import wsgiref.simple_server | |
with wsgiref.simple_server.make_server("", 8000, app) as server: | |
server.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment