From d2e31bb684c530a845da3b8b79b9c29b49c1c71d Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 25 Aug 2023 15:51:47 +1000 Subject: [PATCH] main: Initial dashboard --- master/main.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/master/main.py b/master/main.py index 45ffc35..e6c0ae2 100644 --- a/master/main.py +++ b/master/main.py @@ -390,6 +390,61 @@ def workerIP(worker): return ip +# Home page +@app.route('/') +def home(): + # Show stats and info + + # Get worker info + workers = [] + try: + workers_file = open('/data/workers.txt', 'r') + workers = workers_file.readlines() + workers_file.close() + except FileNotFoundError: + pass + + # Get site info + sites = [] + try: + sites_file = open('/data/sites.txt', 'r') + sites = sites_file.readlines() + sites_file.close() + except FileNotFoundError: + pass + + # Get licence info + licences = [] + try: + licences_file = open('/data/licence_key.txt', 'r') + licences = licences_file.readlines() + licences_file.close() + except FileNotFoundError: + pass + + # Create html page + html = "

Stats


" + html += "

Workers

" + html += "

Number of workers: " + str(len(workers)) + "

" + html += "

Workers:

" + html += "" + html += "

Sites

" + html += "

Number of sites: " + str(len(sites)) + "

" + html += "

Sites:

" + html += "" + html += "

Licences

" + html += "

Number of licences: " + str(len(licences)) + "

" + + + + + # Start the server if __name__ == '__main__': app.run(debug=False, port=5000, host='0.0.0.0') \ No newline at end of file