From 2faf6233e02d81e1e54f48a67934e4278b344484 Mon Sep 17 00:00:00 2001 From: alvierahman90 Date: Tue, 24 Oct 2017 22:17:45 +0100 Subject: [PATCH] takes configuration from same file as gunicorn --- .gitignore | 1 + templates/upload.html | 2 +- templates/upload_success.html | 4 ++-- uploadr.py | 17 ++++++++++++----- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index dc6e631..2b605b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ uploads/* +config.py diff --git a/templates/upload.html b/templates/upload.html index ab175cb..ac0599d 100644 --- a/templates/upload.html +++ b/templates/upload.html @@ -5,7 +5,7 @@ -
Upload diff --git a/templates/upload_success.html b/templates/upload_success.html index e78cec7..8bef4e6 100644 --- a/templates/upload_success.html +++ b/templates/upload_success.html @@ -9,8 +9,8 @@
diff --git a/uploadr.py b/uploadr.py index 0b0101e..6bd9f33 100644 --- a/uploadr.py +++ b/uploadr.py @@ -1,15 +1,17 @@ import time import flask +import config from flask import Flask from flask import render_template from flask import request from flask import send_from_directory from werkzeug.utils import secure_filename - app = Flask(__name__) -port = 8080 -ip = "192.168.1.80" +@app.route("/") +@app.route("/hello/") +def hello(name=None): + return render_template('hello.html',name=name) @app.route('/upload', methods=['GET','POST']) def upload_file(): @@ -18,9 +20,14 @@ def upload_file(): print(secure_filename(f.filename)) filename = str(time.time()) + '.' + secure_filename(f.filename).split('.')[-1] f.save('./uploads/' + filename) - return render_template('upload_success.html', filename = filename, port = port, ip = ip) + return render_template('upload_success.html', + filename = filename, + port = config.port, + ) else: - return render_template('upload.html', port = port, ip = ip) + return render_template('upload.html', + port = config.port, + ) @app.route('/download/') def download(filename=None):