Kingston_Pendrive/Suli/13.b/Frontend/Javascript/2024. 11. 18/server.js

41 lines
903 B
JavaScript
Raw Normal View History

2024-11-19 18:04:02 +00:00
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) => {
let adat =
fs.readFile("F:\\Suli\\13.b\\Frontend\\Javascript\\2024. 11. 18\\public\\json/munkavallalok.json", "utf8", (err, data) => {
adat = data
console.log();
})
console.log(adat);
fs.appendFile("F:\\Suli\\13.b\\Frontend\\Javascript\\2024. 11. 18\\public\\json/munkavallalok.json", adat, (err, data) => {
if (err) {
console.log(err);
return
}
else {
console.log("Sikeres feltöltés!");
}
})
})
app.listen(3000)