liaison python et html
This commit is contained in:
@@ -3,6 +3,7 @@ from flask_talisman import Talisman
|
||||
from led import led
|
||||
import os
|
||||
import sys
|
||||
import log
|
||||
from add_user import add_user
|
||||
import auth
|
||||
import re
|
||||
@@ -16,6 +17,8 @@ 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 alarme import SystemeAlarme
|
||||
from lumiere import SystemeLumieres
|
||||
from board1main import *
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
@@ -38,8 +41,25 @@ def dashboard():
|
||||
|
||||
@app.route("/led", methods=["POST"])
|
||||
def call_led():
|
||||
led(current_user)
|
||||
etat = SystemeLumieres.mettreAJourEtat()
|
||||
if (etat == 0):
|
||||
SystemeLumieres.allumerLumieres
|
||||
|
||||
else:
|
||||
SystemeLumieres.eteindreLumieres()
|
||||
return jsonify({"success": True})
|
||||
@app.route("/board1",methods=["POST"])
|
||||
def board1():
|
||||
try:
|
||||
call_board1()
|
||||
return jsonify({"succes": True})
|
||||
|
||||
except error as e:
|
||||
log.error(f"erreur : {e}")
|
||||
return jsonify({"success": False})
|
||||
|
||||
|
||||
|
||||
@app.route("/alarme",methods=["POST"])
|
||||
def armer_alarme():
|
||||
SystemeAlarme.armer()
|
||||
|
||||
@@ -262,6 +262,11 @@
|
||||
<span class="a-label">💡 Alarme</span>
|
||||
<span class="a-sub">Contrôler la alarme</span>
|
||||
<span class="a-arrow">›</span>
|
||||
</button>
|
||||
<button class="action-btn" onclick="callBoard1()">
|
||||
<span class="a-label">💡 Board1</span>
|
||||
<span class="a-sub">Contrôler la board1</span>
|
||||
<span class="a-arrow">›</span>
|
||||
</button>
|
||||
<button class="action-btn" onclick="showToast('Fonction à venir...')">
|
||||
<span class="a-label">⚙️ Paramètres</span>
|
||||
@@ -308,7 +313,8 @@
|
||||
} catch {
|
||||
showToast("Erreur lors de l'appel LED.");
|
||||
}
|
||||
} async function callAlarm() {
|
||||
}
|
||||
async function callAlarm() {
|
||||
try {
|
||||
const res = await fetch('/alarme', {
|
||||
method: 'POST',
|
||||
@@ -319,6 +325,17 @@
|
||||
showToast("Erreur lors de l'appel alarme.");
|
||||
}
|
||||
}
|
||||
async function callBoard1() {
|
||||
try {
|
||||
const res = await fetch('/board1', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
showToast("board1 activée !");
|
||||
} catch {
|
||||
showToast("Erreur lors de l'appel board1.");
|
||||
}
|
||||
}
|
||||
|
||||
function go_admin() {
|
||||
window.location.href = "/admin";
|
||||
|
||||
Reference in New Issue
Block a user