Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions app.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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']
Expand All @@ -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)
if ssl:
app.run(debug=True, port=5443, ssl_context='adhoc')
else:
app.run(debug=True)
18 changes: 18 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions templates/header.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE html>
{% assets "js_all" %}
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
{% endassets %} {% assets "css_all" %}
{% endassets %}
{% assets "css_all" %}
<link rel=stylesheet type="text/css" href="{{ ASSET_URL }}"> {% endassets %}
<style>
header .branding {
Expand Down Expand Up @@ -31,4 +32,4 @@
<body>
{% block body %}{% endblock %}
</body>
</html>
</html>