filemetadata/index.js

29 lines
703 B
JavaScript
Raw Normal View History

2023-03-29 08:37:29 +02:00
const express = require("express");
const cors = require("cors");
2023-03-29 08:43:39 +02:00
const multer = require("multer");
const upload = multer({ storage: multer.memoryStorage() });
2023-03-29 08:24:36 +02:00
require("dotenv").config();
2017-02-18 20:02:08 +01:00
2023-03-29 08:37:29 +02:00
const PORT = process.env.PORT || 57268;
const app = express();
2017-02-18 20:02:08 +01:00
app.use(cors());
2023-03-29 08:24:36 +02:00
app.use("/public", express.static(process.cwd() + "/public"));
2017-02-18 20:02:08 +01:00
2023-03-29 08:24:36 +02:00
app.get("/", function (req, res) {
res.sendFile(process.cwd() + "/views/index.html");
2017-02-18 20:02:08 +01:00
});
2023-03-29 08:43:39 +02:00
app.post("/api/fileanalyse", upload.single("upfile"), (req, res) => {
res.json({
name: req.file?.originalname,
type: req.file?.mimetype,
size: req.file?.size,
});
2023-03-29 08:37:29 +02:00
});
app.listen(PORT, function () {
console.log("Your app is listening on port " + PORT);
2017-02-18 20:02:08 +01:00
});