mirror of
https://github.com/KevinMidboe/Node-Com-Handler.git
synced 2025-10-29 09:40:27 +00:00
Changed how much logic is in app.py
This commit is contained in:
51
app.py
51
app.py
@@ -12,10 +12,11 @@ from werkzeug.security import generate_password_hash, \
|
||||
|
||||
from status.diskusage import diskUsage
|
||||
from status.uptime import timeSinceBoot
|
||||
from status.load import load
|
||||
from status.cpuTemp import getCpuTemp
|
||||
from plex.tmdb import tmdbSearch
|
||||
|
||||
from plex.plexMovies import getSpecificMovieInfo
|
||||
from plex.tmdb import tmdbSearch
|
||||
from plex.plexSearch import plexSearch
|
||||
|
||||
app = Flask(__name__, static_url_path = "")
|
||||
auth = HTTPBasicAuth()
|
||||
@@ -67,32 +68,24 @@ def bad_request(error):
|
||||
|
||||
|
||||
# --- Apollo Activity --- #
|
||||
@app.route('/api/v1/load', methods=['GET'])
|
||||
def get_load():
|
||||
return jsonify(load())
|
||||
|
||||
|
||||
@app.route('/api/v1/disks', methods=['GET'])
|
||||
@auth.login_required
|
||||
def get_diskUsage():
|
||||
returningDiskUsage = diskUsage(request.args.get('dir'))
|
||||
if returningDiskUsage != None:
|
||||
return jsonify(returningDiskUsage)
|
||||
else:
|
||||
abort(404)
|
||||
return jsonify(diskUsage(request.args.get('dir')))
|
||||
|
||||
|
||||
@app.route('/api/v1/uptimes', methods=['GET'])
|
||||
@auth.login_required
|
||||
def get_uptimes():
|
||||
try:
|
||||
return jsonify({ 'uptime': timeSinceBoot() })
|
||||
except:
|
||||
abort(404)
|
||||
return jsonify({ 'uptime': timeSinceBoot() })
|
||||
|
||||
@app.route('/api/v1/temps', methods=['GET'])
|
||||
def get_temps():
|
||||
cpuTemp = getCpuTemp()
|
||||
if cpuTemp != None:
|
||||
return jsonify( {"Avg cpu temp": cpuTemp} )
|
||||
else:
|
||||
return jsonify( {"Error":"Temp reading not supported for host machine."} )
|
||||
return jsonify(getCpuTemp())
|
||||
|
||||
|
||||
# TODO PLEX
|
||||
# Search, watching, +photo
|
||||
@@ -106,12 +99,12 @@ def get_movieRequest():
|
||||
else: return jsonify({ "Error": "Query not defined." })
|
||||
|
||||
@app.route('/api/v1/plex/movies', methods=['GET'])
|
||||
@auth.login_required
|
||||
def getPlexMovies():
|
||||
title = request.args.get('title')
|
||||
|
||||
movieInfo = getSpecificMovieInfo(title)
|
||||
movieInfo = plexSearch(title)
|
||||
if movieInfo != None:
|
||||
print(movieInfo)
|
||||
return jsonify(movieInfo)
|
||||
|
||||
abort(500)
|
||||
@@ -127,24 +120,6 @@ def getPlexWatchings():
|
||||
return jsonify(movieInfo)
|
||||
|
||||
|
||||
@app.route('/api/v1/uptimes/duration', methods=['GET'])
|
||||
@auth.login_required
|
||||
def get_uptimesDuration():
|
||||
up = uptime.uptime()
|
||||
return jsonify( {'Duration': up.duration} )
|
||||
|
||||
@app.route('/api/v1/uptimes/users', methods=['GET'])
|
||||
@auth.login_required
|
||||
def get_uptimesUsers():
|
||||
up = uptime.uptime()
|
||||
return jsonify( {'Users': up.users} )
|
||||
|
||||
@app.route('/api/v1/uptimes/load', methods=['GET'])
|
||||
@auth.login_required
|
||||
def get_uptimesLoad():
|
||||
up = uptime.uptime()
|
||||
return jsonify( {'Load': up.load} )
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host="0.0.0.0",port=63590, debug=True)
|
||||
|
||||
Reference in New Issue
Block a user