Change upload and qr code folders to variables in config

This commit is contained in:
alvierahman90 2017-10-25 13:26:49 +01:00
parent ebe6398493
commit 587bdd059a
2 changed files with 4 additions and 2 deletions

View File

@ -8,6 +8,8 @@ gunicorn. Here is an example below:
class uploadr: class uploadr:
domain = "example.com" domain = "example.com"
port = 8005 port = 8005
uploads = '/home/dannydevito/uploads' # folder where uploaded files will be stored
qrcodes = '/home/dannydevito/qrcodes' # folder where generated qr codes will be stored
# gunicorn # gunicorn
bind = "0.0.0.0:" + uploadr.port bind = "0.0.0.0:" + uploadr.port

View File

@ -44,7 +44,7 @@ def qrcodes(filename):
image = qrcode.make(link) image = qrcode.make(link)
with open('qrcodes/' + filename+ '.png', mode = 'bw+') as file: with open('qrcodes/' + filename+ '.png', mode = 'bw+') as file:
image.save(file) image.save(file)
return send_from_directory('qrcodes', filename + '.png', as_attachment=True) return send_from_directory(config.qrcodes, filename + '.png', as_attachment=True)
@app.route('/qr/<filename>') @app.route('/qr/<filename>')
def qr(filename=None): def qr(filename=None):
@ -58,7 +58,7 @@ def qr(filename=None):
@app.route('/download/<filename>') @app.route('/download/<filename>')
def download(filename=None): def download(filename=None):
if filename != None: if filename != None:
return flask.send_from_directory('uploads', filename, as_attachment=True) return flask.send_from_directory(config.uploads, filename, as_attachment=True)
else: else:
return hello() return hello()