Update Lesson 6 Task 2 to collect more data
This commit is contained in:
parent
c7c250333b
commit
c77d218010
3 changed files with 18 additions and 5 deletions
1
Lesson_6/Task 2/.gitignore
vendored
1
Lesson_6/Task 2/.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
|
__pycache__
|
||||||
data.db
|
data.db
|
||||||
|
|
|
@ -7,12 +7,18 @@
|
||||||
<form action="/send">
|
<form action="/send">
|
||||||
<label for="cpu">CPU: </label><br>
|
<label for="cpu">CPU: </label><br>
|
||||||
<input type="checkbox" id="cpu" name="cpu"><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>
|
<label for="architecture">Architecture: </label><br>
|
||||||
<input type="checkbox" id="architecture" name="architecture"><br>
|
<input type="checkbox" id="architecture" name="architecture"><br>
|
||||||
<label for="family">Family: </label><br>
|
<label for="family">Family: </label><br>
|
||||||
<input type="checkbox" id="family" name="family"><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>
|
<button id="submit" type="submit">Submit</button>
|
||||||
</form>
|
</form>
|
||||||
Collected data:
|
Collected data:
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
from databaseWorker import *
|
from databaseWorker import *
|
||||||
from flask import Flask, render_template, redirect, request
|
from flask import Flask, render_template, redirect, request
|
||||||
import platform, psutil, os
|
import platform, psutil, os, serial.tools.list_ports
|
||||||
|
|
||||||
app = Flask("Computer info")
|
app = Flask("Computer info")
|
||||||
prepareDb("data.db")
|
prepareDb("data.db")
|
||||||
|
@ -21,12 +21,18 @@ def send():
|
||||||
|
|
||||||
if request.args.get('cpu'):
|
if request.args.get('cpu'):
|
||||||
sendData("data.db", "CPU", platform.processor())
|
sendData("data.db", "CPU", platform.processor())
|
||||||
if request.args.get('ram'):
|
|
||||||
sendData("data.db", "RAM", str(psutil.virtual_memory()))
|
|
||||||
if request.args.get('architecture'):
|
if request.args.get('architecture'):
|
||||||
sendData("data.db", "Architecture", str(platform.architecture()))
|
sendData("data.db", "Architecture", str(platform.architecture()))
|
||||||
if request.args.get('family'):
|
if request.args.get('family'):
|
||||||
sendData("data.db", "Family", platform.machine())
|
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('/')
|
return redirect('/')
|
||||||
|
|
||||||
app.run(host='0.0.0.0', port=8081)
|
app.run(host='0.0.0.0', port=8081)
|
||||||
|
|
Reference in a new issue