Skip to content

Commit

Permalink
add route for getting db size
Browse files Browse the repository at this point in the history
  • Loading branch information
HadronCollider committed May 24, 2022
1 parent 18bf077 commit ca499d4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ca499d4

Please sign in to comment.