diff --git a/master/main.py b/master/main.py index 9b38814..b075002 100644 --- a/master/main.py +++ b/master/main.py @@ -443,7 +443,7 @@ def home(): html += "

Licences

" html += "

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

" - html += "

API

" + html += "

Admin

" return html # Admin page @@ -457,15 +457,69 @@ def admin(): if login_key not in logins: return "

Admin


" - return "

Admin


Logged in" + # Show some admin stuff + licences = [] + try: + licences_file = open('/data/licence_key.txt', 'r') + licences = licences_file.readlines() + licences_file.close() + except FileNotFoundError: + pass + + # Create html page + html = "

Admin


" + html += "

Licences

" + html += "

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

" + html += "

Licences:

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

API

" + html += "

API key: " + os.getenv('LICENCE_KEY') + "

" + html += "

Worker key: " + os.getenv('WORKER_KEY') + "

" + html += "

Stripe

" + # Check if stripe is enabled + if os.getenv('STRIPE_SECRET') == None: + html += "

Stripe is not enabled

" + else: + html += "

Stripe is enabled

" + + html += "

Workers

" + for worker in list_workers().json()['workers']: + html += "

Worker: " + worker['worker'] + " | IP: " + worker['ip'] + " | Status: " + worker['status'] + " | Sites: " + str(worker['sites']) + "

" + + html += "

Sites

" + sites = [] + try: + sites_file = open('/data/sites.txt', 'r') + sites = sites_file.readlines() + sites_file.close() + except FileNotFoundError: + pass + + for site in sites: + html += "

Domain: " + site.split(':')[0] + " | Worker: " + site.split(':')[1].strip('\n') + "

" + + html += "


" + + html += "

Logout

" + html += "

Logout

" + + + return html @app.route('/login', methods=['POST']) def login(): # Handle login print('Login attempt', flush=True) + # Check if form contains password + if 'password' not in request.form: + print('Login failed', flush=True) + return redirect('/failed-login') + password = request.form['password'] - print('Password: ' + password, flush=True) if os.getenv('ADMIN_KEY') == password: print('Login success', flush=True) # Generate login key