From 820caa171bc92733b2f609c2d69ff4dd73af0dbb Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 6 Jun 2018 11:27:23 -0400 Subject: [PATCH] Download link for export --- app.py | 10 +++++++++- templates/downloads.html | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 5c16cff..28780d5 100644 --- a/app.py +++ b/app.py @@ -1,4 +1,4 @@ -from flask import Flask, render_template, redirect, request, flash, abort, Response +from flask import Flask, render_template, redirect, request, flash, abort, Response, send_from_directory import os import json import time @@ -41,6 +41,14 @@ def downloads(): return render_template("downloads.html", export_file_stats=export_file_stats) +@app.route("/get_export") +def get_export(): + + if os.path.exists("static/out.csv.xz"): + return send_from_directory("static", "out.csv.xz", as_attachment=True, mimetype="application/x-xz") + return abort(404) + + @app.route("/website//") def website_info(website_id): diff --git a/templates/downloads.html b/templates/downloads.html index 397e6e6..31c6d09 100644 --- a/templates/downloads.html +++ b/templates/downloads.html @@ -23,7 +23,7 @@ {% if export_file_stats %} - out.csv.xz + out.csv.xz {{ export_file_stats.st_size }} {{ export_file_stats.st_mtime|datetime_format }}