Skip to content

Instantly share code, notes, and snippets.

View davidwtbuxton's full-sized avatar

David Buxton davidwtbuxton

View GitHub Profile
@davidwtbuxton
davidwtbuxton / app.yaml
Created July 21, 2025 09:08
App Engine standard + Python redirect app
runtime: python313
handlers:
- url: /.*
script: auto
secure: always
automatic_scaling:
max_instances: 1
@davidwtbuxton
davidwtbuxton / main.py
Created July 15, 2025 08:17
Fetching the deployed files for an App Engine standard app
"""
Install: gcloud SDK, and configure application default credentials.
https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login
Install: python -m pip install click google-api-python-client google-cloud-storage
Usage:
main.py versions --project=my-proj
main.py download --project=my-proj --version=my-version --service=default
@davidwtbuxton
davidwtbuxton / compose.yaml
Created April 24, 2025 08:18
Docker compose with an nginx proxy for a Python app
# Nginx will listen on localhost:8080, serving static assets and doing gzip compression.
services:
app:
image: python:3.13-alpine
ports: ["8000:8000"]
command: ["python", "-m", "http.server"]
nginx:
build:
@davidwtbuxton
davidwtbuxton / README.md
Created April 8, 2025 10:01
Minimal Python + App Engine standard deployment
@davidwtbuxton
davidwtbuxton / cloudbuild.yaml
Created November 7, 2024 15:23
Google Cloud Build steps to run Django database migrations against Cloud SQL
steps:
- id: build-temp-image
name: gcr.io/cloud-builders/docker
script: |
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
# A custom image with Python + cloud-sql-proxy. We can then use this for
# connecting to the database when running django commands.
@davidwtbuxton
davidwtbuxton / googlememcached.py
Created September 24, 2024 08:22
Cache backend for Python 3 + Django using App Engine's built-in memcached service
# You need to enable `app_engine_apis: true` to use the built-in memcache
# service on App Engine standard.
# https://github.com/GoogleCloudPlatform/appengine-python-standard
#
# Then configure a custom cache backend.
# https://docs.djangoproject.com/en/5.1/ref/settings/#backend
import logging
from django.core.cache.backends.memcached import BaseMemcachedCache
@davidwtbuxton
davidwtbuxton / app.yaml
Last active August 31, 2023 11:17
Serve a Google-looking 404 page for all requests
# For App Engine.
runtime: python311
# Setup for Ubuntu 20.04
# ======================
# Install Nomad, Consul, Docker
# -----------------------------
# GPG keys for Nomad and Docker.
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
@davidwtbuxton
davidwtbuxton / app.yaml
Created September 8, 2021 10:43
Python App Engine test for the Firebase Admin SDK list users API
runtime: python38
@davidwtbuxton
davidwtbuxton / app.yaml
Created March 23, 2021 18:33
Example of App Engine static website with Python redirect handler
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.