I wrote this for Whitenoise today, I hope it is ok to share it here. Also, I've never 'shared' anything anywhere before, so I hope I have done it correctly.