This commit is contained in:
2026-03-30 17:49:18 +02:00
parent 50a48c5292
commit 474a10aa43
3 changed files with 129 additions and 0 deletions

25
fastapi/main.py Normal file
View File

@@ -0,0 +1,25 @@
from fastapi import FastAPI
from pydantic import BaseModel
import os
import sys
app = FastAPI(title="Loustiques API - Pi 2")
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
composants = os.path.join(BASE_DIR, "composants", "byPanda")
sys.path.insert(0, composants)
from lumieres import SystemeLumieres
class CommandeLumiere(BaseModel):
action: str
@app.post("/Lumière")
async def action_pi2(commande: CommandeLumiere):
if commande.action == "allumer_lumiere":
return {"success": True, "message": "Lumière allumée par le Pi 2"}
return {"success": False, "message": "Action inconnue"}