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 led import led
|
||||
import os
|
||||
import sys
|
||||
from add_user import add_user
|
||||
import auth
|
||||
import re
|
||||
@@ -11,6 +12,11 @@ Talisman(app, force_https=True,
|
||||
content_security_policy=False )
|
||||
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("/")
|
||||
def index():
|
||||
return render_template("index.html")
|
||||
@@ -34,6 +40,13 @@ def dashboard():
|
||||
def call_led():
|
||||
led(current_user)
|
||||
return jsonify({"success": True})
|
||||
@app.route("/alarme",methods=["POST"])
|
||||
def armer_alarme():
|
||||
SystemeAlarme.armer()
|
||||
return jsonify({"success": True})
|
||||
|
||||
|
||||
|
||||
|
||||
@app.route("/admin")
|
||||
def admin_page():
|
||||
@@ -69,9 +82,6 @@ def get_users():
|
||||
users = auth.get_users()
|
||||
return jsonify({"success": True, "users": users})
|
||||
|
||||
import os
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(
|
||||
|
||||
@@ -257,6 +257,11 @@
|
||||
<span class="a-label">💡 LED</span>
|
||||
<span class="a-sub">Contrôler la LED</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 class="action-btn" onclick="showToast('Fonction à venir...')">
|
||||
<span class="a-label">⚙️ Paramètres</span>
|
||||
@@ -292,6 +297,7 @@
|
||||
updateClock();
|
||||
setInterval(updateClock, 1000);
|
||||
|
||||
|
||||
async function callLed() {
|
||||
try {
|
||||
const res = await fetch('/led', {
|
||||
@@ -302,6 +308,16 @@
|
||||
} catch {
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user