Initial commit
This commit is contained in:
commit
62a5597ae0
22 changed files with 595 additions and 0 deletions
70
ESP32/static/busylight-api.js
Normal file
70
ESP32/static/busylight-api.js
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
async function setStatus(status = '') {
|
||||
// Les options par défaut sont indiquées par *
|
||||
const response = await fetch(`/api/status/${status}`, {
|
||||
method: "POST", // *GET, POST, PUT, DELETE, etc.
|
||||
cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
});
|
||||
return response.json(); // transforme la réponse JSON reçue en objet JavaScript natif
|
||||
}
|
||||
|
||||
async function getStatus() {
|
||||
// Les options par défaut sont indiquées par *
|
||||
const response = await fetch(`/api/status`, {
|
||||
method: "GET", // *GET, POST, PUT, DELETE, etc.
|
||||
cache: "no-cache" // *default, no-cache, reload, force-cache, only-if-cached
|
||||
});
|
||||
return response.json(); // transforme la réponse JSON reçue en objet JavaScript natif
|
||||
}
|
||||
|
||||
async function setColor(color = {}) {
|
||||
// Les options par défaut sont indiquées par *
|
||||
const response = await fetch(`/api/color`, {
|
||||
method: "POST", // *GET, POST, PUT, DELETE, etc.
|
||||
cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(color) // le type utilisé pour le corps doit correspondre à l'en-tête "Content-Type"
|
||||
});
|
||||
return response.json(); // transforme la réponse JSON reçue en objet JavaScript natif
|
||||
}
|
||||
|
||||
async function getColor() {
|
||||
// Les options par défaut sont indiquées par *
|
||||
const response = await fetch(`/api/color`, {
|
||||
method: "GET", // *GET, POST, PUT, DELETE, etc.
|
||||
cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
});
|
||||
return response.json(); // transforme la réponse JSON reçue en objet JavaScript natif
|
||||
}
|
||||
|
||||
async function setBrightness(brightness = {}) {
|
||||
// Les options par défaut sont indiquées par *
|
||||
const response = await fetch(`/api/brightness`, {
|
||||
method: "POST", // *GET, POST, PUT, DELETE, etc.
|
||||
cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(brightness) // le type utilisé pour le corps doit correspondre à l'en-tête "Content-Type"
|
||||
});
|
||||
return response.json(); // transforme la réponse JSON reçue en objet JavaScript natif
|
||||
}
|
||||
|
||||
async function getBrightness() {
|
||||
// Les options par défaut sont indiquées par *
|
||||
const response = await fetch(`/api/brightness`, {
|
||||
method: "GET", // *GET, POST, PUT, DELETE, etc.
|
||||
cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
});
|
||||
return response.json(); // transforme la réponse JSON reçue en objet JavaScript natif
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue