The output I am getting:
Server listening on port 3001
Received file upload request
Uploaded filename: The History of AI.pdf
Python script execution complete. Exit code: 0
Sending summary to frontend: 
All further log statements from the frontend are not getting executed and I am not getting my summary to the frontend 
frontend.html:
<!DOCTYPE html>
<html lang=“en”>
<head>
<meta charset=“UTF-8”>
<meta name=“viewport” content=“width=device-width, initial-scale=1.0”>
<title>File Upload</title>
</head>
<body>
<form id=“uploadForm” action=“/upload” method=“POST” enctype=“multipart/form-data”>
<input type=“file” name=“uploadFile” />
<button type=“submit”>Upload</button>
</form>
<p id=“summary”></p>

<script>
document.getElementById(“uploadForm”).addEventListener(“submit”, async (event) => {
event.preventDefault();
const formData = new FormData(event.target);

try {
const response = await fetch(“http://127.0.0.1:3001/upload”, {
method: “POST”,
body: formData
});

if (!response.ok) {
throw new Error(HTTP error! Status: ${response.status});
}

const data = await response.json();
if (data.error) {
console.error(data.error);
} else {
displaySummary(data.summary);
console.log(data.filename);
}
} catch (error) {
console.error(“Fetch error:”, error);
}
});

function displaySummary(summary) {
try {
console.log(“Received summary from server:”, summary);
// Use innerText instead of textContent to handle HTML content
document.getElementById(“summary”).innerText = summary;
} catch (error) {
console.error(“Error displaying summary:”, error);
}
}

</script>
</body>
</html>

app.js:
const express = require("express");
const multer = require("multer");
const cors = require("cors");
const { spawn } = require("child_process");


const app = express();
const port = 3001;

const storage = multer.diskStorage({
  destination: function (req, file, cb) {
    return cb(null, "./uploads");
  },
  filename: function (req, file, cb) {
    return cb(null, `${file.originalname}`);
 } 
})

const upload = multer({ storage: storage });

app.use(cors());
app.use(express.urlencoded({ extended: false }));

app.post("/upload", upload.single("uploadFile"), (req, res) => {
  console.log("Received file upload request");
  
  if (!req.file) {
    console.log("No file uploaded");
    return res.status(400).json({ error: "No file uploaded" });
  }

  const filename = req.file.originalname;
  console.log("Uploaded filename:", filename);

  const pythonProcess = spawn("python", ["summarizer.py", req.file.path]);

  let summary = "";
  pythonProcess.stdout.on("data", (data) => {
    summary += data.toString();
  });

  pythonProcess.on("close", (code) => {
    console.log("Python script execution complete. Exit code:", code);
    if (code === 0) {
      console.log("Sending summary to frontend:", summary);
      res.json({ summary, filename });
    } else {
      console.log("Error in Python script. Sending 500 response.");
      res.status(500).json({ error: "An error occurred in the Python script" });
    }
  });

  pythonProcess.stderr.on("data", (error) => {
    console.error(error.toString());
    console.log("Error in Python script. Sending 500 response.");
    res.status(500).json({ error: "An error occurred in the Python script" });
  });
});


app.listen(port, () => {
  console.log(`Server listening on port ${port}`);
});