Created
June 5, 2018 23:45
-
-
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)
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
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