diff --git a/templates/qr.html b/templates/qr.html
new file mode 100644
index 0000000..a03b4b3
--- /dev/null
+++ b/templates/qr.html
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/templates/upload_success.html b/templates/upload_success.html
index 8bef4e6..29016a5 100644
--- a/templates/upload_success.html
+++ b/templates/upload_success.html
@@ -5,13 +5,7 @@
Upload success!
diff --git a/uploadr.py b/uploadr.py
index 48cd54a..19928d8 100644
--- a/uploadr.py
+++ b/uploadr.py
@@ -1,11 +1,12 @@
import time
import flask
-import config
import os
+import qrcode
from flask import Flask
from flask import render_template
from flask import request
from flask import send_from_directory
+from config import uploadr as config
from werkzeug.utils import secure_filename
app = Flask(__name__)
app.config['SECRET_KEY'] = os.urandom(24)
@@ -31,6 +32,27 @@ def upload_file():
port = config.port,
)
+@app.route('/qrcodes/')
+def qrcodes(filename):
+ link = 'http://{0}:{1}/download/{2}'.format(
+ config.domain
+ , config.port
+ , filename
+ )
+ image = qrcode.make(link)
+ with open('qrcodes/' + filename+ '.png', mode = 'bw+') as file:
+ image.save(file)
+ return send_from_directory('qrcodes', filename + '.png', as_attachment=True)
+
+@app.route('/qr/')
+def qr(filename=None):
+ return render_template('qr.html', imagesrc = 'http://{0}:{1}/qrcodes/{2}'.format(
+ config.domain
+ , config.port
+ , filename
+ )
+ )
+
@app.route('/download/')
def download(filename=None):
if filename != None:
@@ -38,7 +60,6 @@ def download(filename=None):
else:
return hello()
-
@app.route('/css/')
def css(filename=None):
return flask.send_from_directory('css', filename)