mise en place code panda sur html
This commit is contained in:
@@ -2,6 +2,7 @@ from flask import Flask, render_template, request, jsonify
|
|||||||
from flask_talisman import Talisman
|
from flask_talisman import Talisman
|
||||||
from led import led
|
from led import led
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from add_user import add_user
|
from add_user import add_user
|
||||||
import auth
|
import auth
|
||||||
import re
|
import re
|
||||||
@@ -11,6 +12,11 @@ Talisman(app, force_https=True,
|
|||||||
content_security_policy=False )
|
content_security_policy=False )
|
||||||
current_user = None
|
current_user = None
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
return render_template("index.html")
|
return render_template("index.html")
|
||||||
@@ -34,6 +40,13 @@ def dashboard():
|
|||||||
def call_led():
|
def call_led():
|
||||||
led(current_user)
|
led(current_user)
|
||||||
return jsonify({"success": True})
|
return jsonify({"success": True})
|
||||||
|
@app.route("/alarme",methods=["POST"])
|
||||||
|
def armer_alarme():
|
||||||
|
SystemeAlarme.armer()
|
||||||
|
return jsonify({"success": True})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/admin")
|
@app.route("/admin")
|
||||||
def admin_page():
|
def admin_page():
|
||||||
@@ -69,9 +82,6 @@ def get_users():
|
|||||||
users = auth.get_users()
|
users = auth.get_users()
|
||||||
return jsonify({"success": True, "users": users})
|
return jsonify({"success": True, "users": users})
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(
|
app.run(
|
||||||
|
|||||||
@@ -257,6 +257,11 @@
|
|||||||
<span class="a-label">💡 LED</span>
|
<span class="a-label">💡 LED</span>
|
||||||
<span class="a-sub">Contrôler la LED</span>
|
<span class="a-sub">Contrôler la LED</span>
|
||||||
<span class="a-arrow">›</span>
|
<span class="a-arrow">›</span>
|
||||||
|
</button>
|
||||||
|
<button class="action-btn" onclick="callAlarm()">
|
||||||
|
<span class="a-label">💡 Alarme</span>
|
||||||
|
<span class="a-sub">Contrôler la alarme</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>
|
||||||
@@ -292,6 +297,7 @@
|
|||||||
updateClock();
|
updateClock();
|
||||||
setInterval(updateClock, 1000);
|
setInterval(updateClock, 1000);
|
||||||
|
|
||||||
|
|
||||||
async function callLed() {
|
async function callLed() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/led', {
|
const res = await fetch('/led', {
|
||||||
@@ -302,6 +308,16 @@
|
|||||||
} catch {
|
} catch {
|
||||||
showToast("Erreur lors de l'appel LED.");
|
showToast("Erreur lors de l'appel LED.");
|
||||||
}
|
}
|
||||||
|
} async function callAlarm() {
|
||||||
|
try {
|
||||||
|
const res = await fetch('/alarme', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
});
|
||||||
|
showToast("alarme activée !");
|
||||||
|
} catch {
|
||||||
|
showToast("Erreur lors de l'appel alarme.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function go_admin() {
|
function go_admin() {
|
||||||
|
|||||||
Reference in New Issue
Block a user