This is a working prototype of the webview.

This commit is contained in:
Alexis Werefox 2021-08-04 23:28:42 -05:00
parent 6c19a5f940
commit ab131088b1
4 changed files with 56 additions and 6 deletions

1
.gitignore vendored
View file

@ -1,3 +1,2 @@
**.pyc **.pyc
**/__pycache__/** **/__pycache__/**
data/**

26
app.py
View file

@ -1,11 +1,29 @@
from flask import Flask from flask import Flask, render_template
from powerpanel_manage import get_status_dict from src.powerpanel_manage import get_status_dict
app = Flask(__name__) app = Flask(__name__)
def format_status_dict():
status_dict = get_status_dict()
info_dict = {
'Rating Voltage': status_dict['Rating Voltage'],
'Rating Power': status_dict['Rating Power'],
'State': status_dict['State']
}
title_dict = {
'Model Name': status_dict['Model Name'],
'Firmware Number': status_dict['Firmware Number'],
'Power Supply by': status_dict['Power Supply by']
}
for key in info_dict.keys():
status_dict.pop(key)
for key in title_dict.keys():
status_dict.pop(key)
return (title_dict, info_dict, status_dict)
@app.route('/') @app.route('/')
def main_page(): def main_page():
status_dict = get_status_dict() title_dict, info_dict, status_dict = format_status_dict()
return status_dict return render_template('index.html', title_dict=title_dict, info_dict=info_dict, status_dict=status_dict)
if __name__ == '__main__': if __name__ == '__main__':
app.run(host='0.0.0.0', port=9090) app.run(host='0.0.0.0', port=9090)

View file

@ -11,4 +11,4 @@ def get_status_dict():
def print_status_dict(dict): def print_status_dict(dict):
for i in dict.keys(): for i in dict.keys():
print('{}\t\t\t{}'.format(i, dict[i])) print(f'{i}\t\t\t{dict[i]}')

33
templates/index.html Normal file
View file

@ -0,0 +1,33 @@
<!doctype html>
<html>
<head>
<title>PowerPanel Webview</title>
<link rel="stylesheet" href="https://unpkg.com/xp.css">
</head>
<body style="background-color: gray;">
<div class="window">
<div class="title-bar">
<div class="title-bar-text">PowerPanel Info | Power Supply by: {{ title_dict['Power Supply by'] }} | Model: {{ title_dict['Model Name'] }} | Firmware: {{ title_dict['Firmware Number'] }}</div>
<div class="title-bar-controls">
<button aria-label="Minimize"></button>
<button aria-label="Maximize"></button>
<button aria-label="Close"></button>
</div>
</div>
<div class="window-body">
{% for item in status_dict.keys() %}
<h3>{{ item }}</h3>
<p style="font-size:x-large">{{ status_dict[item] }}</p>
{% endfor %}
</div>
<div class="status-bar">
{% for item in info_dict.keys() %}
<p class="status-bar-field" style="font-size: large;">{{ item }}: {{ info_dict[item] }}</p>
{% endfor %}
</div>
</div>
</body>
</html>