Google App Engine
During the development of Simple Site Checker I realised that it would be useful for test purposes if there is a website returning all possible HTTP status codes. Thanks to Google App Engine and webapp2 framework building such website was a piece of cake.
The site can be found at http://httpstatuscodes.appspot.com.
The home page provides a list of all HTTP status codes and their names and if you want to get an HTTP response with a specific status code just add the code after the slash, example:
http://httpstatuscodes.appspot.com/200 – returns 200 OK
http://httpstatuscodes.appspot.com/500 – returns 500 Internal Server Error
Also at the end of each page is located the URL of the HTTP protocol Status Codes Definitions with detailed explanation for each one of them.
The website code is publicly available in github at HTTP Status Codes Site.
If you find it useful feel free to comment and/or share it.
… or how to find the date of week in specified timezone, no matter where your server is.
The problem: I maintain a site targeting user in single country(single timezone) and I have to create administration based on a day of week(show this on Monday, that on Tuesday etc.). The site is based on Google App Engine Platform.
The simplest and most obvious solutions is to take the current time and add/substract the difference between server timezone and your target timezone. Unfortunately this is not going to work in our case.
Speciality: As you may know google have multiple data centers all over the world.
(more info at
So you can not be sure which server is currently responsible for your app. Also you have a DST(daylight saving time) that also must be included in calculation. Fortunately you can use UTC time and
PyTZ for GAE.
from datetime import datetime, timedelta from pytz import timezone import pytz bg_zone = timezone('Europe/Sofia') bg_zone_time = bg_zone.localize(datetime.utcnow()) day_of_week = bg_zone_time.strftime("%w")
#5) create timezone object corresponding to your timezone(in my case this is Europe/Sofia)
#6) get the correct time for the specified timezone calling localize method of the timezone object with current UTC time as parameter
#7) using time formatting to get the day of week. There is simple catch here, at first I try it with weekday() method and get incorrect results. It looks like the method ignores the timezone/DST correction, so you have to use strftime().
Final words: I didn`t test all methods so I couldn`t say which one ignores the timezone and which not, but I hope this article will be helpful for someone facing this or similar problem. Any correction and code improvements will be appreciated.