return normal urls

This commit is contained in:
Ivan 2024-02-02 01:34:44 +03:00
parent 7643b0f957
commit 80513466d5
Signed by untrusted user who does not match committer: ppechenkoo
GPG Key ID: 0C191B86D9582583

183
server.js
View File

@ -120,7 +120,7 @@ app.post("/videos/restart", async (req, res) => {
var options = { var options = {
method: "GET", method: "GET",
url: `/http/restart`, url: `http://${process.env.VIRTUAL_HOST}/http/restart`,
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
data: { video: true }, data: { video: true },
}; };
@ -2756,7 +2756,7 @@ app.post("/update-group", async (req, res) => {
async function getParameters(serial) { async function getParameters(serial) {
const requestResponse = await axios.get( const requestResponse = await axios.get(
`/http/parameters/request?serial=${serial}`, `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`,
{ {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -2770,7 +2770,7 @@ async function getParameters(serial) {
await new Promise((resolve) => setTimeout(resolve, 300)); await new Promise((resolve) => setTimeout(resolve, 300));
const requestResponse2 = await axios.get( const requestResponse2 = await axios.get(
`/http/parameters/request?serial=${serial}`, `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`,
{ {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -2784,7 +2784,7 @@ async function getParameters(serial) {
await new Promise((resolve) => setTimeout(resolve, 300)); await new Promise((resolve) => setTimeout(resolve, 300));
const requestResponse3 = await axios.get( const requestResponse3 = await axios.get(
`/http/parameters/request?serial=${serial}`, `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`,
{ {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -2798,7 +2798,7 @@ async function getParameters(serial) {
await new Promise((resolve) => setTimeout(resolve, 300)); await new Promise((resolve) => setTimeout(resolve, 300));
const requestResponse5 = await axios.get( const requestResponse5 = await axios.get(
`/http/parameters/request?serial=${serial}`, `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`,
{ {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -2809,10 +2809,12 @@ async function getParameters(serial) {
} }
); );
console.log(requestResponse.data); // console.log(requestResponse.data);
await new Promise((resolve) => setTimeout(resolve, 300)); await new Promise((resolve) => setTimeout(resolve, 300));
const getResponse = await axios.get(`/http/parameters/get?serial=${serial}`); const getResponse = await axios.get(
`http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}`
);
return getResponse.data; return getResponse.data;
} }
@ -2831,7 +2833,7 @@ app.post("/main-parameters", async (req, res) => {
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
const requestResponse = await axios.get( const requestResponse = await axios.get(
`/http/parameters/request?serial=${serial}`, `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`,
{ {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -2845,7 +2847,7 @@ app.post("/main-parameters", async (req, res) => {
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
const getResponse = await axios.get( const getResponse = await axios.get(
`/http/parameters/get?serial=${serial}` `http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}`
); );
res.json(getResponse.data); res.json(getResponse.data);
@ -2886,12 +2888,15 @@ app.put("/main-parameters", async (req, res) => {
.status(400) .status(400)
.send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); .send("Ошибка: lastkeepalive старше минуты или устройство не найдено.");
} }
const response = await axios.get(`/http/parameters/set?serial=${serial}`, { const response = await axios.get(
data: JSON.stringify(requestBody), `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`,
headers: { {
"Content-Type": "application/json", data: JSON.stringify(requestBody),
}, headers: {
}); "Content-Type": "application/json",
},
}
);
res.status(response.status).send(response.data); res.status(response.status).send(response.data);
} catch (error) { } catch (error) {
res.status(500).send("Произошла ошибка при отправке GET запроса."); res.status(500).send("Произошла ошибка при отправке GET запроса.");
@ -2934,7 +2939,7 @@ app.post("/ethernet-parameters", async (req, res) => {
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
const requestResponse = await axios.get( const requestResponse = await axios.get(
`/http/parameters/request?serial=${serial}`, `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`,
{ {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -2948,7 +2953,7 @@ app.post("/ethernet-parameters", async (req, res) => {
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
const getResponse = await axios.get( const getResponse = await axios.get(
`/http/parameters/get?serial=${serial}` `http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}`
); );
res.json(getResponse.data); res.json(getResponse.data);
@ -2999,12 +3004,15 @@ app.put("/ethernet-parameters", async (req, res) => {
.status(400) .status(400)
.send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); .send("Ошибка: lastkeepalive старше минуты или устройство не найдено.");
} }
const response = await axios.get(`/http/parameters/set?serial=${serial}`, { const response = await axios.get(
data: JSON.stringify(requestBody), `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`,
headers: { {
"Content-Type": "application/json", data: JSON.stringify(requestBody),
}, headers: {
}); "Content-Type": "application/json",
},
}
);
res.status(response.status).send(response.data); res.status(response.status).send(response.data);
} catch (error) { } catch (error) {
res.status(500).send("Произошла ошибка при отправке GET запроса."); res.status(500).send("Произошла ошибка при отправке GET запроса.");
@ -3025,7 +3033,7 @@ app.post("/wifi-parameters", async (req, res) => {
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
const requestResponse = await axios.get( const requestResponse = await axios.get(
`/http/parameters/request?serial=${serial}`, `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`,
{ {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -3039,7 +3047,7 @@ app.post("/wifi-parameters", async (req, res) => {
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
const getResponse = await axios.get( const getResponse = await axios.get(
`/http/parameters/get?serial=${serial}` `http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}`
); );
res.json(getResponse.data); res.json(getResponse.data);
@ -3086,12 +3094,15 @@ app.put("/wifi-parameters", async (req, res) => {
.status(400) .status(400)
.send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); .send("Ошибка: lastkeepalive старше минуты или устройство не найдено.");
} }
const response = await axios.get(`/http/parameters/set?serial=${serial}`, { const response = await axios.get(
data: JSON.stringify(requestBody), `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`,
headers: { {
"Content-Type": "application/json", data: JSON.stringify(requestBody),
}, headers: {
}); "Content-Type": "application/json",
},
}
);
res.status(response.status).send(response.data); res.status(response.status).send(response.data);
} catch (error) { } catch (error) {
res.status(500).send("Произошла ошибка при отправке GET запроса."); res.status(500).send("Произошла ошибка при отправке GET запроса.");
@ -3112,7 +3123,7 @@ app.post("/communication-parameters", async (req, res) => {
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
const requestResponse = await axios.get( const requestResponse = await axios.get(
`/http/parameters/request?serial=${serial}`, `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`,
{ {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -3126,7 +3137,7 @@ app.post("/communication-parameters", async (req, res) => {
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
const getResponse = await axios.get( const getResponse = await axios.get(
`/http/parameters/get?serial=${serial}` `http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}`
); );
res.json(getResponse.data); res.json(getResponse.data);
@ -3182,12 +3193,15 @@ app.put("/communication-parameters", async (req, res) => {
.status(400) .status(400)
.send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); .send("Ошибка: lastkeepalive старше минуты или устройство не найдено.");
} }
const response = await axios.get(`/http/parameters/set?serial=${serial}`, { const response = await axios.get(
data: JSON.stringify(requestBody), `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`,
headers: { {
"Content-Type": "application/json", data: JSON.stringify(requestBody),
}, headers: {
}); "Content-Type": "application/json",
},
}
);
res.status(response.status).send(response.data); res.status(response.status).send(response.data);
} catch (error) { } catch (error) {
res.status(500).send("Произошла ошибка при отправке GET запроса."); res.status(500).send("Произошла ошибка при отправке GET запроса.");
@ -3208,7 +3222,7 @@ app.post("/install-parameters", async (req, res) => {
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
const requestResponse = await axios.get( const requestResponse = await axios.get(
`/http/parameters/request?serial=${serial}`, `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`,
{ {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -3222,7 +3236,7 @@ app.post("/install-parameters", async (req, res) => {
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
const getResponse = await axios.get( const getResponse = await axios.get(
`/http/parameters/get?serial=${serial}` `http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}`
); );
res.json(getResponse.data); res.json(getResponse.data);
@ -3246,7 +3260,7 @@ app.post("/ai-parameters", async (req, res) => {
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
const requestResponse = await axios.get( const requestResponse = await axios.get(
`/http/parameters/request?serial=${serial}`, `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`,
{ {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -3260,7 +3274,7 @@ app.post("/ai-parameters", async (req, res) => {
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
const getResponse = await axios.get( const getResponse = await axios.get(
`/http/parameters/get?serial=${serial}` `http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}`
); );
res.json(getResponse.data); res.json(getResponse.data);
@ -3300,12 +3314,15 @@ app.put("/ai-parameters", async (req, res) => {
.status(400) .status(400)
.send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); .send("Ошибка: lastkeepalive старше минуты или устройство не найдено.");
} }
const response = await axios.get(`/http/parameters/set?serial=${serial}`, { const response = await axios.get(
data: JSON.stringify(requestBody), `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`,
headers: { {
"Content-Type": "application/json", data: JSON.stringify(requestBody),
}, headers: {
}); "Content-Type": "application/json",
},
}
);
res.status(response.status).send(response.data); res.status(response.status).send(response.data);
} catch (error) { } catch (error) {
res.status(500).send("Произошла ошибка при отправке GET запроса."); res.status(500).send("Произошла ошибка при отправке GET запроса.");
@ -3326,7 +3343,7 @@ app.post("/cameras-parameters", async (req, res) => {
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
const requestResponse = await axios.get( const requestResponse = await axios.get(
`/http/parameters/request?serial=${serial}`, `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`,
{ {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -3340,7 +3357,7 @@ app.post("/cameras-parameters", async (req, res) => {
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
const getResponse = await axios.get( const getResponse = await axios.get(
`/http/parameters/get?serial=${serial}` `http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}`
); );
res.json(getResponse.data); res.json(getResponse.data);
@ -3376,12 +3393,15 @@ app.put("/cameras-parameters", async (req, res) => {
.status(400) .status(400)
.send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); .send("Ошибка: lastkeepalive старше минуты или устройство не найдено.");
} }
const response = await axios.get(`/http/parameters/set?serial=${serial}`, { const response = await axios.get(
data: JSON.stringify(requestBody), `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`,
headers: { {
"Content-Type": "application/json", data: JSON.stringify(requestBody),
}, headers: {
}); "Content-Type": "application/json",
},
}
);
res.status(response.status).send(response.data); res.status(response.status).send(response.data);
} catch (error) { } catch (error) {
res.status(500).send("Произошла ошибка при отправке GET запроса."); res.status(500).send("Произошла ошибка при отправке GET запроса.");
@ -3417,12 +3437,15 @@ app.put("/install-parameters", async (req, res) => {
.status(400) .status(400)
.send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); .send("Ошибка: lastkeepalive старше минуты или устройство не найдено.");
} }
const response = await axios.get(`/http/parameters/set?serial=${serial}`, { const response = await axios.get(
data: JSON.stringify(requestBody), `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`,
headers: { {
"Content-Type": "application/json", data: JSON.stringify(requestBody),
}, headers: {
}); "Content-Type": "application/json",
},
}
);
res.status(response.status).send(response.data); res.status(response.status).send(response.data);
} catch (error) { } catch (error) {
res.status(500).send("Произошла ошибка при отправке GET запроса."); res.status(500).send("Произошла ошибка при отправке GET запроса.");
@ -3812,12 +3835,15 @@ app.put("/device-parameters", async (req, res) => {
.status(400) .status(400)
.send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); .send("Ошибка: lastkeepalive старше минуты или устройство не найдено.");
} }
const response = await axios.get(`/http/parameters/set?serial=${serial}`, { const response = await axios.get(
data: JSON.stringify(requestBody), `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`,
headers: { {
"Content-Type": "application/json", data: JSON.stringify(requestBody),
}, headers: {
}); "Content-Type": "application/json",
},
}
);
res.status(response.status).send(response.data); res.status(response.status).send(response.data);
} catch (error) { } catch (error) {
res.status(500).send("Произошла ошибка при отправке GET запроса."); res.status(500).send("Произошла ошибка при отправке GET запроса.");
@ -3850,12 +3876,15 @@ app.put("/camera-parameters", async (req, res) => {
.status(400) .status(400)
.send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); .send("Ошибка: lastkeepalive старше минуты или устройство не найдено.");
} }
const response = await axios.get(`/http/parameters/set?serial=${serial}`, { const response = await axios.get(
data: JSON.stringify(requestBody), `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`,
headers: { {
"Content-Type": "application/json", data: JSON.stringify(requestBody),
}, headers: {
}); "Content-Type": "application/json",
},
}
);
res.status(response.status).send(response.data); res.status(response.status).send(response.data);
} catch (error) { } catch (error) {
res.status(500).send("Произошла ошибка при отправке GET запроса."); res.status(500).send("Произошла ошибка при отправке GET запроса.");
@ -5052,12 +5081,12 @@ app.get("/getData", async (req, res) => {
try { try {
const successResponse = await axios.get( const successResponse = await axios.get(
`/http/filelist/request?serial=${selectedSerial}&querytime=${selectedDate}&channel=${selectedChannel}` `http://${process.env.VIRTUAL_HOST}/http/filelist/request?serial=${selectedSerial}&querytime=${selectedDate}&channel=${selectedChannel}`
); );
if (successResponse.data.SUCCESS) { if (successResponse.data.SUCCESS) {
await new Promise((resolve) => setTimeout(resolve, 7000)); await new Promise((resolve) => setTimeout(resolve, 7000));
const dataResponse = await axios.get( const dataResponse = await axios.get(
`/http/filelist/get?serial=${selectedSerial}&querytime=${selectedDate}&channel=${selectedChannel}` `http://${process.env.VIRTUAL_HOST}/http/filelist/get?serial=${selectedSerial}&querytime=${selectedDate}&channel=${selectedChannel}`
); );
if (successResponse.data.SUCCESS) { if (successResponse.data.SUCCESS) {
const dataId = dataResponse.data.DATAID; const dataId = dataResponse.data.DATAID;