.
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.cache import Cache
app.config['CACHE_TYPE'] = 'simple'
app.cache = Cache(app)
@app.route('/thtop', methods=['GET'])
@app.cache.cached(timeout=60)
def thtop():
now = datetime.now()
now_time = now.time()
if now_time >= time(3,30) and now_time <= time(16,30):
rv = app.cache.get('last_response')
else:
rv = 'abcc'
app.cache.set('last_response', rv, timeout=3600)
return rv
however, when it is in the time range, it will return Exception on /thtop [GET]#012Traceback (most recent call last):#012 File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1687, in wsgi_app#012 response = self.full_dispatch_request()#012 File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1361, in full_dispatch_request#012 response = self.make_response(rv)#012 File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1439, in make_response#012 raise ValueError('View function did not return a response')#012ValueError: View function did not return a response
[edit by admin: formatting]