diff --git a/__pycache__/app.cpython-313.pyc b/__pycache__/app.cpython-313.pyc
new file mode 100644
index 0000000..aa4832a
Binary files /dev/null and b/__pycache__/app.cpython-313.pyc differ
diff --git a/__pycache__/grabber.cpython-313.pyc b/__pycache__/grabber.cpython-313.pyc
new file mode 100644
index 0000000..80c97c2
Binary files /dev/null and b/__pycache__/grabber.cpython-313.pyc differ
diff --git a/app.py b/app.py
index c2b59d3..38c48f3 100644
--- a/app.py
+++ b/app.py
@@ -8,15 +8,8 @@ from grabber import Grabber
app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
templates = Jinja2Templates(directory="templates")
-
ordi1 = Grabber()
-@app.get("/ordi1", response_class=HTMLResponse)
-async def read_item(request: Request):
- return templates.TemplateResponse(
- request=request, name="ordi.html", context={"ordi": ordi1}
- )
-
@app.post("/endpoint")
async def receive_info(request: Request):
# Lire le body brut
@@ -29,13 +22,31 @@ async def receive_info(request: Request):
except json.JSONDecodeError:
raise HTTPException(status_code=400, detail="Invalid JSON")
- # Debug
- print("Data grabbed :", data)
-
- ordi1.hostname = data['HARDWARE']['hostname']
- ordi1.mb_serial = data['HARDWARE']['mb_serial']
+ hw = data["HARDWARE"]
+ sw = data["SOFTWARE"]
- print(f"Hostname is {ordi1.hostname}")
+ ordi1.host = hw["hostname"]
+ ordi1.cpu = hw["cpu_model"]
+ ordi1.cpu_id = hw["cpu_id"]
+ ordi1.cpu_cores_number = hw["cpu_cores"]
+ ordi1.cpu_threads_number = hw["cpu_threads"]
+ ordi1.cpu_frequency_min = hw["cpu_frequency_min"]
+ ordi1.cpu_frequency_cur = hw["cpu_frequency_cur"]
+ ordi1.cpu_frequency_max = hw["cpu_frequency_max"]
+
+
+ ordi1.os = sw["os"]
+ ordi1.arch = sw["arch"]
+ ordi1.desktop = sw["desktop_env"]
+ ordi1.wm = sw["window_manager"]
+ ordi1.kernel = sw["kernel"]
+
+ print(f"Hostname is {ordi1.host}")
print(f"Motherboard serial is {ordi1.mb_serial}")
- return {"status": "ok"}
\ No newline at end of file
+ return {"status": "ok"}
+
+
+@app.get("/ordi1") #page affichant les infos de l'ordi
+async def show_info(request: Request):
+ return templates.TemplateResponse("item.html", {"request": request, "ordi": ordi1})
\ No newline at end of file
diff --git a/grabber.sh b/grabber.sh
index a32ddad..f13939e 100755
--- a/grabber.sh
+++ b/grabber.sh
@@ -360,14 +360,6 @@ python_venv() {
source gbvenv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
- if [ ! -d "./static" ]; then
- echo "static folder doesn't exist, creating one..."
- mkdir static
- fi
- if [ ! -d "./ordi1" ]; then
- echo "1st computer folder doesn't exist, creating one..."
- mkdir ordi1
- fi
uvicorn app:app --reload --host 0.0.0.0 --port 8000
}
diff --git a/templates/item.html b/templates/item.html
new file mode 100644
index 0000000..e8d119f
--- /dev/null
+++ b/templates/item.html
@@ -0,0 +1,48 @@
+
+
+
+
+
+ Informations Système
+
+
+
+ Informations de l'Ordinateur
+
+
+
[HARDWARE]
+
+ | Propriété | Valeur |
+ | Hostname | {{ ordi.hostname }} |
+ | CPU | {{ ordi.cpu_model }} |
+ | ID CPU | {{ ordi.cpu_id }} |
+ | Nombre de Cœurs CPU | {{ ordi.cpu_cores }} |
+ | Nombre de Threads CPU | {{ ordi.cpu_threads }} |
+ | Fréquence Min CPU | {{ ordi.cpu_frequency_min }} |
+ | Fréquence Courante CPU | {{ ordi.cpu_frequency_cur }} |
+ | Fréquence Max CPU | {{ ordi.cpu_frequency_max }} |
+ | Nombre de slots de RAM | {{ ordi.ram_slots }} |
+
+
+
+
+
[SOFTWARE]
+
+ | Propriété | Valeur |
+ | OS | {{ ordi.os }} |
+ | Architecture | {{ ordi.arch }} |
+ | Desktop | {{ ordi.desktop_env }} |
+ | Window Manager | {{ ordi.window_manager }} |
+ | Kernel | {{ ordi.kernel }} |
+
+
+
+