This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
powerpanel-webview/app.py

30 lines
984 B
Python
Raw Normal View History

from flask import Flask, render_template
from src.powerpanel_manage import get_status_dict
2021-08-04 21:46:59 -05:00
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)
2021-08-04 21:46:59 -05:00
@app.route('/')
def main_page():
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)
2021-08-04 21:46:59 -05:00
if __name__ == '__main__':
app.run(host='0.0.0.0', port=9090)