Last active
January 13, 2024 21:03
-
-
Save arthurbenemann/a0fd09b0ddcaff8649430bb0de43b2f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import Flask, render_template_string | |
| import subprocess | |
| import socket | |
| app = Flask(__name__) | |
| @app.route('/') | |
| def index(): | |
| ip_a_output = subprocess.check_output(['ip', 'a'], text=True) | |
| lspci_output = subprocess.check_output(['lspci'], text=True) | |
| lsusb_output = subprocess.check_output(['lsusb'], text=True) | |
| sensors_output = subprocess.check_output(['sensors'], text=True) | |
| fqdn = socket.getfqdn() | |
| return render_template_string(HTML_TEMPLATE, fqdn=fqdn, ip_a_output=ip_a_output, | |
| sensors_output=sensors_output, lspci_output=lspci_output, | |
| lsusb_output=lsusb_output) | |
| if __name__ == '__main__': | |
| PORT = 8000 | |
| HTML_TEMPLATE = """ | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>{{ fqdn }}</title> | |
| <style> | |
| .collapsible { | |
| cursor: pointer; | |
| padding: 10px; | |
| width: 100%; | |
| text-align: left; | |
| border: none; | |
| outline: none; | |
| background-color: #f1f1f1; | |
| font-size: 18px; | |
| } | |
| .content { | |
| display: none; | |
| overflow: hidden; | |
| background-color: #f9f9f9; | |
| padding: 10px; | |
| } | |
| </style> | |
| <script> | |
| function toggleSection(sectionId) { | |
| var content = document.getElementById(sectionId); | |
| content.style.display = (content.style.display === 'none') ? 'block' : 'none'; | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <h1>{{ fqdn }}</h1> | |
| <button class="collapsible" onclick="toggleSection('sensorsSection')">lm-sensors Devices</button> | |
| <div class="content" id="sensorsSection" style="display: block;"><pre>{{ sensors_output }}</pre></div> | |
| <button class="collapsible" onclick="toggleSection('ipASection')">ip a Output</button> | |
| <div class="content" id="ipASection"><pre>{{ ip_a_output }}</pre></div> | |
| <button class="collapsible" onclick="toggleSection('lspciSection')">lspci Output</button> | |
| <div class="content" id="lspciSection"><pre>{{ lspci_output }}</pre></div> | |
| <button class="collapsible" onclick="toggleSection('lsusbSection')">lsusb Output</button> | |
| <div class="content" id="lsusbSection"><pre>{{ lsusb_output }}</pre></div> | |
| </body> | |
| </html> | |
| """ | |
| app.run(debug=True, host='0.0.0.0', port=PORT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment