Impl: project requirements

This commit is contained in:
Manish 2023-03-29 17:43:39 +11:00
parent aa91c119d8
commit dc32554e22

View File

@ -1,5 +1,7 @@
const express = require("express"); const express = require("express");
const cors = require("cors"); const cors = require("cors");
const multer = require("multer");
const upload = multer({ storage: multer.memoryStorage() });
require("dotenv").config(); require("dotenv").config();
const PORT = process.env.PORT || 57268; const PORT = process.env.PORT || 57268;
@ -13,8 +15,12 @@ app.get("/", function (req, res) {
res.sendFile(process.cwd() + "/views/index.html"); res.sendFile(process.cwd() + "/views/index.html");
}); });
app.post("/api/fileanalyse", (req, res) => { app.post("/api/fileanalyse", upload.single("upfile"), (req, res) => {
res.json({ Hello: ", World!" }); res.json({
name: req.file?.originalname,
type: req.file?.mimetype,
size: req.file?.size,
});
}); });
app.listen(PORT, function () { app.listen(PORT, function () {