From ebe6398493dddcb86b0be9cb6df4dab8ec5711bf Mon Sep 17 00:00:00 2001 From: alvierahman90 Date: Wed, 25 Oct 2017 13:26:03 +0100 Subject: [PATCH] Automatically create directories if non existant --- README.md | 2 -- uploadr.py | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e0e9e92..5fbd6c9 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,6 @@ class uploadr: # gunicorn bind = "0.0.0.0:" + uploadr.port ``` - -You also need to create the directories `qrcodes` and `uploads` (in your working directory). ## dependencies uploadr uses the following modules: - `flask` diff --git a/uploadr.py b/uploadr.py index f9deaab..db783bf 100644 --- a/uploadr.py +++ b/uploadr.py @@ -11,6 +11,12 @@ from werkzeug.utils import secure_filename app = Flask(__name__) app.config['SECRET_KEY'] = os.urandom(24) +if not os.path.isdir(config.uploads): + os.makedirs(config.uploads) + +if not os.path.isdir(config.qrcodes): + os.makedirs(config.qrcodes) + @app.route("/") @app.route('/upload', methods=['GET','POST']) def upload_file():