last-modified.py (499B)
1 from wptserve.utils import isomorphic_decode, isomorphic_encode 2 3 def main(request, response): 4 import datetime, os 5 srcpath = os.path.join(os.path.dirname(isomorphic_decode(__file__)), u"well-formed.xml") 6 srcmoddt = datetime.datetime.utcfromtimestamp(os.path.getmtime(srcpath)) 7 response.headers.set(b"Last-Modified", isomorphic_encode(srcmoddt.strftime(u"%a, %d %b %Y %H:%M:%S GMT"))) 8 response.headers.set(b"Content-Type", b"application/xml") 9 return open(srcpath, u"r").read()