Skip to content

Instantly share code, notes, and snippets.

@Ogreman
Created August 11, 2015 13:17
Show Gist options
  • Save Ogreman/59cc6fe4a29658eb0531 to your computer and use it in GitHub Desktop.
Save Ogreman/59cc6fe4a29658eb0531 to your computer and use it in GitHub Desktop.
import json
from flask import request, url_for
from flask.ext.api import FlaskAPI, status, exceptions
from werkzeug.contrib.cache import SimpleCache
app = FlaskAPI(__name__)
cache = SimpleCache()
def get_data():
data = cache.get('json')
if data is None:
with open('linkdump.json', 'r') as f:
data = json.load(f)
cache.set('json', data, timeout=30 * 60)
return data
@app.route("/", methods=['GET'])
def index():
return get_data()
if __name__ == "__main__":
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment