Skip to content

Commit

Permalink
added images into response, from server-app/recognised_
Browse files Browse the repository at this point in the history
a
  • Loading branch information
BurdujaAdrian committed Oct 30, 2024
1 parent d67927b commit 3247c0e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Binary file modified database/pb_data/logs.db
Binary file not shown.
24 changes: 23 additions & 1 deletion database/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,29 @@ func main() {
return c.String(http.StatusInternalServerError, "error runing the python scrips")
}

return c.String(http.StatusOK, string(output))
// Get list of images from the 'recognised_faces' folder
recognisedFacesPath := "../server-app/recognised_faces/"
files, err := os.ReadDir(recognisedFacesPath)
if err != nil {
return c.String(http.StatusInternalServerError, "Error reading recognised faces folder")
}

var faceImages []string
for _, file := range files {
if !file.IsDir() {
// Optionally, read and encode image content in base64, or just send filenames
filePath := recognisedFacesPath + file.Name()
faceImages = append(faceImages, filePath)
}
}

// Create a response containing the script output and the list of recognised faces
response := map[string]interface{}{
"python_output": string(output),
"recognised_faces": faceImages,
}

return c.JSON(http.StatusOK, response)
}, apis.ActivityLogger(app))

return nil
Expand Down

0 comments on commit 3247c0e

Please sign in to comment.