mirror of
https://github.com/alvierahman90/uploadr.git
synced 2025-01-12 10:14:21 +00:00
Change upload and qr code folders to variables in config
This commit is contained in:
parent
ebe6398493
commit
587bdd059a
@ -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
|
||||||
|
@ -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()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user