Update Lesson 6 Task 2 to collect more data

This commit is contained in:
Stanislav Mykhailenko 2023-01-23 22:48:15 +02:00
parent c7c250333b
commit c77d218010
GPG key ID: 1E95E66A9C9D6A36
3 changed files with 18 additions and 5 deletions

View file

@ -1 +1,2 @@
__pycache__
data.db

View file

@ -7,12 +7,18 @@
<form action="/send">
<label for="cpu">CPU: </label><br>
<input type="checkbox" id="cpu" name="cpu"><br>
<label for="ram">RAM: </label><br>
<input type="checkbox" id="ram" name="ram"><br>
<label for="architecture">Architecture: </label><br>
<input type="checkbox" id="architecture" name="architecture"><br>
<label for="family">Family: </label><br>
<input type="checkbox" id="family" name="family"><br>
<label for="ram">RAM: </label><br>
<input type="checkbox" id="ram" name="ram"><br>
<label for="os">Operating system: </label><br>
<input type="checkbox" id="os" name="os"><br>
<label for="disk">Disk usage: </label><br>
<input type="checkbox" id="disk" name="disk"><br>
<label for="serial">Serial ports: </label><br>
<input type="checkbox" id="serial" name="serial"><br>
<button id="submit" type="submit">Submit</button>
</form>
Collected data:

View file

@ -4,7 +4,7 @@
from databaseWorker import *
from flask import Flask, render_template, redirect, request
import platform, psutil, os
import platform, psutil, os, serial.tools.list_ports
app = Flask("Computer info")
prepareDb("data.db")
@ -21,12 +21,18 @@ def send():
if request.args.get('cpu'):
sendData("data.db", "CPU", platform.processor())
if request.args.get('ram'):
sendData("data.db", "RAM", str(psutil.virtual_memory()))
if request.args.get('architecture'):
sendData("data.db", "Architecture", str(platform.architecture()))
if request.args.get('family'):
sendData("data.db", "Family", platform.machine())
if request.args.get('ram'):
sendData("data.db", "RAM", str(psutil.virtual_memory()))
if request.args.get('os'):
sendData("data.db", "Operating system", os.name)
if request.args.get('disk'):
sendData("data.db", "Disk usage", str(psutil.disk_usage(".")))
if request.args.get('serial'):
sendData("data.db", "Serial ports", str(serial.tools.list_ports.comports()))
return redirect('/')
app.run(host='0.0.0.0', port=8081)