Skip to content

Instantly share code, notes, and snippets.

@ruanbekker
Created June 5, 2018 23:45
Show Gist options
  • Save ruanbekker/1d17eef650792220518a8c7fa4829adf to your computer and use it in GitHub Desktop.
Save ruanbekker/1d17eef650792220518a8c7fa4829adf to your computer and use it in GitHub Desktop.
Python Flask-Caching Test using the Simple Cache Option (does not show response cache headers)
from flask import Flask
from flask_caching import Cache
from time import strftime
app = Flask(__name__)
app.config['CACHE_TYPE'] = 'simple'
app.cache = Cache(app)
def get_time():
data = strftime("%Y-%m-%dT-%h-%m-%s")
return data
@app.route('/')
@app.cache.cached(timeout=10)
def index():
return get_time()
if __name__ == '__main__':
app.run(port=809)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment