Fix: FUCK OMBAASE MESSED UP.
This commit is contained in:
@@ -33,9 +33,9 @@ const Ai = () => {
|
||||
throw new Error("Prediction request failed");
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
const result = await response.json();
|
||||
// Assuming the API returns a JSON object with an "output" field.
|
||||
setPrediction(data.output || "No prediction returned");
|
||||
setPrediction(result.data || "No prediction returned");
|
||||
} catch (err) {
|
||||
console.error("Error during prediction:", err);
|
||||
setError(err.message);
|
||||
|
||||
+16
-1
@@ -3,10 +3,19 @@ const express = require("express");
|
||||
const { spawn } = require("child_process");
|
||||
const path = require("path");
|
||||
const upload = require("./Middleware/multer");
|
||||
const cors = require("cors");
|
||||
|
||||
const app = express();
|
||||
const PORT = 3000;
|
||||
|
||||
const corsOptions = {
|
||||
origin: "http://localhost:5173",
|
||||
methods: "GET,HEAD,PUT,PATCH,POST,DELETE",
|
||||
credentials: true,
|
||||
};
|
||||
|
||||
app.use(cors(corsOptions));
|
||||
|
||||
// Endpoint to run the Python script
|
||||
app.post("/predict", upload.single("image"), (req, res) => {
|
||||
console.log("File is uploaded successfully" + req.file?.path);
|
||||
@@ -22,7 +31,13 @@ app.post("/predict", upload.single("image"), (req, res) => {
|
||||
// Collect data from the script
|
||||
pythonProcess.stdout.on("data", (data) => {
|
||||
console.log(`Output: ${data}`);
|
||||
res.send(data.toString()); // Send the output back to the client
|
||||
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
message: "Image uploaded successfully",
|
||||
data: data.toString(),
|
||||
});
|
||||
//res.send(data.toString()); // Send the output back to the client
|
||||
});
|
||||
|
||||
// Handle errors
|
||||
|
||||
Reference in New Issue
Block a user