Created
October 5, 2014 14:38
-
-
Save stavinsky/30ab813f5aa3e394a0f9 to your computer and use it in GitHub Desktop.
cherrypy if-modified-since example
This file contains 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 time | |
import cherrypy | |
now = [2014, 10, 4, 20, 45, 41, 5, 277, 0] | |
class Root(): | |
def index(self): | |
cherrypy.response.headers['Last-Modified'] = cherrypy.lib.httputil.HTTPDate(time.mktime(tuple(now))) | |
cherrypy.lib.cptools.validate_since() | |
return 'Hello world' | |
# example of converting date from datetime to time sctuct: | |
import time | |
from datetime import datetime | |
now = datetime.now() | |
now_st = time.mktime(now.timetuple()) | |
# example from http://stackoverflow.com/questions/3453177/convert-python-datetime-to-rfc-2822 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment