diff --git a/conf.py.sample b/conf.py.sample index 90440bb..85ade3a 100644 --- a/conf.py.sample +++ b/conf.py.sample @@ -17,6 +17,7 @@ config["KEY"] = "" # File settings config["UPLOAD_FOLDER"] = './data' +config["ALLOW_ALL_FILES"] = True config["ALLOWED_EXTENSIONS"] = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif']) # If this is set to true, old files will be deleted. TIME is how far behind (in seconds) the last accessed time can be before files get deleted config["DELETE_FILES"] = True diff --git a/run.py b/run.py index 5bd1547..ca9d717 100755 --- a/run.py +++ b/run.py @@ -58,13 +58,16 @@ def auth(key): def allowed_file(filename): + if config["ALLOW_ALL_FILES"]: + return True + else: return '.' in filename and filename.rsplit('.', 1)[1] in config["ALLOWED_EXTENSIONS"] @app.route('/', methods=['GET', 'POST']) def upload_file(): if request.method == 'POST': - print_log('Web', 'New file Received') + print_log('Web', 'New file received') if not auth(request.headers.get('X-Hyozan-Auth')): abort(403) data = dict() @@ -92,7 +95,8 @@ def upload_file(): except Exception: return json.dumps(data) else: - return render_template('error.html') + print_log('Notice', 'Forbidden file received') + return render_template('error.html', page=config["SITE_DATA"], error="This file isn't allowed, sorry!") # Return Web UI if we have a GET request elif request.method == 'GET': diff --git a/templates/error.html b/templates/error.html index de18a48..d648e4c 100644 --- a/templates/error.html +++ b/templates/error.html @@ -3,5 +3,5 @@

Error

-

Oops, we won't allow you to upload that file at the moment - Sorry

+

{{ error }}

{% endblock %}