Changed port and origin url+methods allowed in models/server.js

This commit is contained in:
K
2025-07-22 16:42:04 +05:30
parent ccd5debcef
commit 45419247f7
+5 -5
View File
@@ -6,11 +6,11 @@ const upload = require("./Middleware/multer");
const cors = require("cors"); const cors = require("cors");
const app = express(); const app = express();
const PORT = 3000; const PORT = 8081;
const corsOptions = { const corsOptions = {
origin: "http://localhost:5173", origin: "http://frontend:3000",
methods: "GET,HEAD,PUT,PATCH,POST,DELETE", methods: "GET,PUT,POST",
credentials: true, credentials: true,
}; };
@@ -18,7 +18,7 @@ app.use(cors(corsOptions));
// Endpoint to run the Python script // Endpoint to run the Python script
app.post("/predict", upload.single("image"), (req, res) => { app.post("/predict", upload.single("image"), (req, res) => {
console.log("File is uploaded successfully" + req.file?.path); console.log("File is uploaded successfully " + req.file?.path);
// const imagePath = path.join(__dirname, req.file?.path); // Path to your image // const imagePath = path.join(__dirname, req.file?.path); // Path to your image
const imagePath = req.file?.path; const imagePath = req.file?.path;
@@ -26,7 +26,7 @@ app.post("/predict", upload.single("image"), (req, res) => {
console.log("Image Path is : ", imagePath); console.log("Image Path is : ", imagePath);
// Spawn a new Python process // Spawn a new Python process
const pythonProcess = spawn("python", ["app.py", imagePath]); const pythonProcess = spawn("python3", ["app.py", imagePath]);
// Collect data from the script // Collect data from the script
pythonProcess.stdout.on("data", (data) => { pythonProcess.stdout.on("data", (data) => {