From a30b9a9ba2405fb70c2d90692ed343fc4db28b01 Mon Sep 17 00:00:00 2001 From: maxime Date: Thu, 2 Apr 2026 22:19:52 +0200 Subject: [PATCH] finally the end of the road --- fastapi/main.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/fastapi/main.py b/fastapi/main.py index 821b007..8ef6707 100644 --- a/fastapi/main.py +++ b/fastapi/main.py @@ -4,6 +4,7 @@ from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware import RPi.GPIO as GPIO import uvicorn +import threading GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) @@ -17,6 +18,11 @@ from thermostat import SystemeThermostat #from volets import SystemeVolets from etatsysteme import EtatSysteme from septsegments import afficher_temperature +import bouton_servo +import bouton +import LDR + + app = FastAPI(title="L'API des loustiques") app.add_middleware( @@ -72,10 +78,24 @@ async def read_temp(): etatSysteme.signalerProbleme() return {"success": False, "message": str(e)} - - +@app.get("/volet_status") +async def volet_status(): + try: + actuel = bouton_servo.etat_porte + return {"success": True, "status": actuel} + except Exception as e: + return {"success": False, "message": str(e)} + +@app.get("/luminosite") +def get_luminosite(): + return ({"success": True, "status": LDR.lire_etat()}) if __name__ == "__main__": + t1 = threading.Thread(target=bouton_servo.test_boutons, daemon=True) + t2 = threading.Thread(target=bouton.test_boutons, daemon=True) + + t1.start() + t2.start() chemin_cle = os.path.join(BASE_DIR, 'web_secu', 'ssl', 'key.pem') chemin_cert = os.path.join(BASE_DIR, 'web_secu', 'ssl', 'cert.pem') uvicorn.run(