diff --git a/.gitignore b/.gitignore index 73a4c0d..280a5ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ **.pyc **/__pycache__/** -data/** diff --git a/app.py b/app.py index 95be2c6..9bf2f77 100644 --- a/app.py +++ b/app.py @@ -1,11 +1,29 @@ -from flask import Flask -from powerpanel_manage import get_status_dict +from flask import Flask, render_template +from src.powerpanel_manage import get_status_dict 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('/') def main_page(): - status_dict = get_status_dict() - return status_dict + title_dict, info_dict, status_dict = format_status_dict() + return render_template('index.html', title_dict=title_dict, info_dict=info_dict, status_dict=status_dict) if __name__ == '__main__': app.run(host='0.0.0.0', port=9090) diff --git a/src/powerpanel_manage.py b/src/powerpanel_manage.py index c77e46b..7e57ae4 100644 --- a/src/powerpanel_manage.py +++ b/src/powerpanel_manage.py @@ -11,4 +11,4 @@ def get_status_dict(): def print_status_dict(dict): for i in dict.keys(): - print('{}\t\t\t{}'.format(i, dict[i])) + print(f'{i}\t\t\t{dict[i]}') diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..ba602e5 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,33 @@ + + + + + PowerPanel Webview + + + + +
+
+
PowerPanel Info | Power Supply by: {{ title_dict['Power Supply by'] }} | Model: {{ title_dict['Model Name'] }} | Firmware: {{ title_dict['Firmware Number'] }}
+
+ + + +
+
+
+ {% for item in status_dict.keys() %} +

{{ item }}

+

{{ status_dict[item] }}

+ {% endfor %} +
+
+ {% for item in info_dict.keys() %} +

{{ item }}: {{ info_dict[item] }}

+ {% endfor %} +
+
+ + + \ No newline at end of file