Angle Double
This commit is contained in:
@@ -208,11 +208,16 @@ app.get('/api/latest-snapshot', (req, res) => {
|
||||
const latestFile = csvFiles[0];
|
||||
const baseName = path.basename(latestFile.name, path.extname(latestFile.name));
|
||||
const jsonFilename = `${baseName}.json`;
|
||||
const jsonPath = path.join(snapshotsDir, jsonFilename);
|
||||
|
||||
console.log("JSON Pfad:", jsonPath);
|
||||
console.log("Existiert JSON:", fs.existsSync(jsonPath));
|
||||
|
||||
const imageFilename = `${baseName}_annotated.jpg`;
|
||||
const imagePath = path.join(snapshotsDir, imageFilename);
|
||||
const imatePath2 = imagePath.includes('video0') ? imagePath.replace('video0', 'video1') : imagePath.replace('video1', 'video0');
|
||||
|
||||
|
||||
//--
|
||||
fs.readFile(latestFile.path, 'utf8', (err, data) => {
|
||||
if (err) {
|
||||
return res.status(500).json({ error: 'Fehler beim Lesen der Datei' });
|
||||
@@ -224,39 +229,45 @@ app.get('/api/latest-snapshot', (req, res) => {
|
||||
content: data
|
||||
};
|
||||
|
||||
// Lade JSON wenn vorhanden
|
||||
fs.readFile(jsonFilename, { encoding: 'base64' }, (jpgErr, jpgBase64) => {
|
||||
if (!jpgErr && jpgBase64) {
|
||||
response.imageFile = {
|
||||
const jsonPath = path.join(snapshotsDir, jsonFilename);
|
||||
|
||||
// ✅ JSON FIRST, dann alles andere
|
||||
fs.readFile(jsonPath, 'utf8', (jsonErr, jsonData) => {
|
||||
if (!jsonErr && jsonData) {
|
||||
response.jsonFile = {
|
||||
filename: jsonFilename,
|
||||
mimeType: 'json',
|
||||
contentBase64: jpgBase64
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Lade beide Bilder
|
||||
fs.readFile(imagePath, { encoding: 'base64' }, (jpgErr, jpgBase64) => {
|
||||
if (!jpgErr && jpgBase64) {
|
||||
response.imageFile = {
|
||||
filename: imageFilename,
|
||||
mimeType: 'image/jpeg',
|
||||
contentBase64: jpgBase64
|
||||
content: jsonData
|
||||
};
|
||||
}
|
||||
|
||||
fs.readFile(imatePath2, { encoding: 'base64' }, (jpgErr2, jpgBase642) => {
|
||||
if (!jpgErr2 && jpgBase642) {
|
||||
response.image2 = {
|
||||
filename: path.basename(imatePath2),
|
||||
// Bild 1
|
||||
fs.readFile(imagePath, { encoding: 'base64' }, (jpgErr, jpgBase64) => {
|
||||
if (!jpgErr && jpgBase64) {
|
||||
response.imageFile = {
|
||||
filename: imageFilename,
|
||||
mimeType: 'image/jpeg',
|
||||
contentBase64: jpgBase642
|
||||
contentBase64: jpgBase64
|
||||
};
|
||||
}
|
||||
res.json(response);
|
||||
|
||||
// Bild 2
|
||||
fs.readFile(imatePath2, { encoding: 'base64' }, (jpgErr2, jpgBase642) => {
|
||||
if (!jpgErr2 && jpgBase642) {
|
||||
response.image2 = {
|
||||
filename: path.basename(imatePath2),
|
||||
mimeType: 'image/jpeg',
|
||||
contentBase64: jpgBase642
|
||||
};
|
||||
}
|
||||
|
||||
// ✅ jetzt erst senden
|
||||
res.json(response);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
//--
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user