diff --git a/app.py b/app.py old mode 100644 new mode 100755 index 8d51e37..2359614 --- a/app.py +++ b/app.py @@ -1,8 +1,12 @@ +#!/usr/bin/env python3 + from flask import Flask, render_template, redirect, request, url_for, jsonify, session from flask_assets import Bundle, Environment import requests from base64 import b64encode +ssl = False + app = Flask(__name__) app.secret_key = "super secret key" @@ -13,9 +17,10 @@ css = Bundle('css/clarity-ui.min.css', 'css/clarity-icons.min.css') env.register('css_all', css) + @app.route('/', methods=["GET", "POST"]) def homepage(): - if request.method == "POST": + if request.method == "POST": attempted_username = request.form['username'] print(attempted_username) attempted_password = request.form['password'] @@ -30,24 +35,29 @@ def homepage(): session['wrong_pass'] = True return render_template('index.html') + @app.route('/vms') def vmlist(): req = requests.get('https://pyva.humblelab.com/rest/vcenter/vms') req_json = req.json() - return render_template('vms.html', vms = req_json) + return render_template('vms.html', vms=req_json) + @app.route('/workflows') def workflows(): url = 'https://hlcloud.humblelab.com' value = b64encode(b"username:password").decode("ascii") headers = { - 'Authorization': 'Basic '+ value, + 'Authorization': 'Basic ' + value, 'content-type': 'application/json', - 'accept' : 'application/json' + 'accept': 'application/json' } req = requests.get('{}/vco/api/workflows/'.format(url), verify=False, headers=headers) return render_template('workflows.html', flows=req.json()['link']) if __name__ == '__main__': - app.run(debug=True) \ No newline at end of file + if ssl: + app.run(debug=True, port=5443, ssl_context='adhoc') + else: + app.run(debug=True) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..15fdebd --- /dev/null +++ b/requirements.txt @@ -0,0 +1,18 @@ +certifi==2020.4.5.1 +cffi==1.14.0 +chardet==3.0.4 +click==7.1.2 +cryptography==2.9.2 +Flask==1.1.2 +Flask-Assets==2.0 +idna==2.9 +itsdangerous==1.1.0 +Jinja2==2.11.2 +MarkupSafe==1.1.1 +pycparser==2.20 +pyOpenSSL==19.1.0 +requests==2.23.0 +six==1.15.0 +urllib3==1.25.9 +webassets==2.0 +Werkzeug==1.0.1 diff --git a/templates/header.html b/templates/header.html index 60337cb..4664006 100644 --- a/templates/header.html +++ b/templates/header.html @@ -1,7 +1,8 @@ {% assets "js_all" %} -{% endassets %} {% assets "css_all" %} +{% endassets %} +{% assets "css_all" %} {% endassets %}