const express = require("express") const app = express() const path = require("path") const fs = require("node:fs") app.set("view engine", "ejs") let initialPath = path.join(__dirname, "public") app.use(express.static(initialPath)); app.use(express.json()) app.get("/", (req, res) => { res.render("index") }) app.post("/feltoltes", (req, res) => { fs.readFile("F:\\Suli\\13.b\\Frontend\\Javascript\\2024. 11. 18\\public\\json/munkavallalok.json", "utf8", (err, data) => { let adat = JSON.parse(data) adat.push(req.body) fs.writeFile("F:\\Suli\\13.b\\Frontend\\Javascript\\2024. 11. 18\\public\\json/munkavallalok.json", JSON.stringify(adat), (err, data) => { if (err) { console.log(err); return } else { console.log("Sikeres feltöltés!"); } }) }) }) app.listen(3000)