def refresh_cache(): """Refreshes the cache""" global cache cache = redshift.build_tiles_cache(force_redownload=True) return jsonify({'message':"Cache refreshed!"})
def refresh_cache(): """Refreshes the cache""" global cache cache = redshift.build_tiles_cache(force_redownload=True) return jsonify({'message': "Cache refreshed!"})
#Essentially put together from this page: http://flask.pocoo.org/docs/0.10/quickstart/ #Just run this like: #> python server.py #and then visit http://localhost:5000 from json import dump, dumps from datetime import datetime from pdb import set_trace from collections import defaultdict from webbrowser import open as open_webpage from flask import Flask, render_template, request, make_response, Response, jsonify import redshift app = Flask(__name__) cache = redshift.build_tiles_cache() #set up database connection #Views @app.route('/download_excel', methods=['GET', 'POST']) def download_excel(): """Creates a file download from recieved post information""" data = request.form["data"] data = data.split("###") data = [[y.replace(",", "") for y in x.split("#")] for x in data] data = "\n".join([','.join(x) for x in data]) #filename = request.form["filename"] response = make_response(data) response.headers["Content-Disposition"] = "attachment; filename=data.csv" return response