Created
August 11, 2015 13:17
-
-
Save Ogreman/59cc6fe4a29658eb0531 to your computer and use it in GitHub Desktop.
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 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