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