diff --git a/app/config.ini b/app/config.ini index a3451fa7..7af02d5c 100644 --- a/app/config.ini +++ b/app/config.ini @@ -1,4 +1,4 @@ [consts] MAX_CONTENT_LENGTH=16 -MAX_SYSTEM_STORAGE=2000 +MAX_SYSTEM_STORAGE=5000 PASSBACK_TIMER=60 diff --git a/app/server.py b/app/server.py index e76f57f0..e6794480 100644 --- a/app/server.py +++ b/app/server.py @@ -493,6 +493,19 @@ def profile(username): abort(403) +@app.route("/capacity", methods=["GET"]) +def system_capacity(): + units = {'b': 1, 'mb':1024**2, 'gb': 1024**3} + unit = units.get(request.args.get('unit', 'gb').lower(), units['gb']) + current_size = data.get_storage() + ratio = current_size / app.config['MAX_SYSTEM_STORAGE'] + return { + 'size': current_size / unit, + 'max_size': app.config['MAX_SYSTEM_STORAGE'] / unit, + 'ratio': ratio + } + + # Handle exceptions @app.errorhandler(413)