From 43ea1bd25b6bfba7cc9cc779db3a01e260864a3a Mon Sep 17 00:00:00 2001 From: Mia Wang <yw21218@ic.ac.uk> Date: Thu, 27 Jan 2022 12:38:59 +0000 Subject: [PATCH] fixed downloading issue --- .gitlab-ci.yml | 2 +- auto_augmentation/__init__.py | 4 +++- auto_augmentation/download_file.py | 4 ++-- auto_augmentation/templates/result.html | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5b0f2666..b125750c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,4 +22,4 @@ deploy-job: - pip install -r requirements.txt - flask run & - echo "Now I'm Deploying to Heroku!" - - dpl --provider=heroku --app=yw21218-simplewebapp --api-key=5ccc3ae7-725e-4f9f-b441-0c9a28ebdc1b + - dpl --provider=heroku --app=metarl --api-key=5ccc3ae7-725e-4f9f-b441-0c9a28ebdc1b diff --git a/auto_augmentation/__init__.py b/auto_augmentation/__init__.py index 163f63b6..da6ac6a4 100644 --- a/auto_augmentation/__init__.py +++ b/auto_augmentation/__init__.py @@ -2,7 +2,7 @@ import os from flask import Flask, render_template, request, flash -from auto_augmentation import home, progress, result, download_file +from auto_augmentation import home, progress,result def create_app(test_config=None): # create and configure the app @@ -21,6 +21,8 @@ def create_app(test_config=None): # ensure the instance folder exists os.makedirs(app.instance_path, exist_ok=True) + from auto_augmentation import download_file + app.register_blueprint(home.bp) app.register_blueprint(progress.bp) app.register_blueprint(result.bp) diff --git a/auto_augmentation/download_file.py b/auto_augmentation/download_file.py index c0dffa0c..35b9f5a9 100644 --- a/auto_augmentation/download_file.py +++ b/auto_augmentation/download_file.py @@ -3,10 +3,10 @@ from flask import Blueprint, request, render_template, flash, send_file bp = Blueprint("download_file", __name__) @bp.route("/download_file", methods=["GET"]) -@bp.route("/choose_file", methods=["GET", "POST"]) +@bp.route("/download", methods=["GET", "POST"]) def download(): # Setup for the 'return send_file()' function call at the end of this function path = 'templates/CNN.zip' # e.g. 'templates/download.markdown' - + return send_file(path, as_attachment=True) diff --git a/auto_augmentation/templates/result.html b/auto_augmentation/templates/result.html index 62c8a456..6e127fdb 100644 --- a/auto_augmentation/templates/result.html +++ b/auto_augmentation/templates/result.html @@ -9,7 +9,9 @@ </div> <div> + <form action="/download"> <input type="submit" value='Download CNN'> + </form> </div> {% endblock %} -- GitLab