lots of php proofreading and html tab tidying up
This commit is contained in:
@ -12,7 +12,6 @@ from requests import RequestException, Response
|
||||
# import needed Class Libraries
|
||||
from Storage import *
|
||||
from Helpers import *
|
||||
#SummaryServer = DriveHealthServer(get_hostname())
|
||||
|
||||
SummaryServer = load_state()
|
||||
|
||||
@ -20,12 +19,12 @@ if SummaryServer is None:
|
||||
SummaryServer = DriveHealthServer(get_hostname())
|
||||
print("Created new SummaryServer")
|
||||
|
||||
# declare flask apps
|
||||
# declare flask app
|
||||
app = Flask(__name__)
|
||||
#scheduler = APScheduler()
|
||||
|
||||
|
||||
############################
|
||||
# Flask routes
|
||||
############################
|
||||
|
||||
# client update
|
||||
@app.route('/storage_client_update', methods=['POST'])
|
||||
@ -49,7 +48,6 @@ def storage_client_delete():
|
||||
print(result)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
# client details
|
||||
@app.route('/client_details', methods=['GET'])
|
||||
def client_details():
|
||||
@ -86,20 +84,15 @@ def test_route():
|
||||
"DriveHealthServer": f"{SummaryServer}"
|
||||
})
|
||||
|
||||
|
||||
# test route 2
|
||||
@app.route('/test_storage_summary', methods=['GET'])
|
||||
def test_storage_summary():
|
||||
return jsonify({
|
||||
"message": "Hello world!",
|
||||
"hostname": get_hostname(),
|
||||
"DriveHealthServer": f"{SummaryServer}"
|
||||
})
|
||||
|
||||
|
||||
return test_route()
|
||||
|
||||
|
||||
############################
|
||||
# Route Helpers
|
||||
############################
|
||||
|
||||
# helper function for client_update route
|
||||
# handles the submission data from the flask route
|
||||
@ -112,6 +105,12 @@ def client_update_helper(payload: dict):
|
||||
result = client_processor(processed_payload)
|
||||
return result
|
||||
|
||||
# client processing function, add/update logic in Class Methods
|
||||
def client_processor(client_dict: dict):
|
||||
result = SummaryServer.process_client_data(client_dict)
|
||||
save_state(SummaryServer)
|
||||
return result
|
||||
|
||||
# handle submission from remove route
|
||||
def client_remove_helper(payload: dict):
|
||||
result = None
|
||||
@ -147,30 +146,12 @@ def post_processor(client_dict: dict, required_keys: dict):
|
||||
client_dict["processed_at"] = time.time()
|
||||
return client_dict
|
||||
|
||||
# Main functions
|
||||
|
||||
# client processing function, add/update logic in Class Methods
|
||||
def client_processor(client_dict: dict):
|
||||
result = SummaryServer.process_client_data(client_dict)
|
||||
save_state(SummaryServer)
|
||||
return result
|
||||
|
||||
def background_loop():
|
||||
return True
|
||||
############################
|
||||
# Main function
|
||||
############################
|
||||
|
||||
def run_main():
|
||||
#if SummaryServer is none:
|
||||
|
||||
#atexit.register(lambda: save_state(SummaryServer)) test
|
||||
# Flask scheduler for background loop, run if requested
|
||||
#scheduler.add_job(id='background_loop',
|
||||
# func=background_loop,
|
||||
# trigger='interval',
|
||||
# seconds=60)
|
||||
#scheduler.init_app(app)
|
||||
#scheduler.start()
|
||||
|
||||
# Flask API
|
||||
background_loop()
|
||||
app.run(debug=False, host='0.0.0.0', port=5001)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user