From 8c32b4861069d1e96d369399fa95cc02d31c47c3 Mon Sep 17 00:00:00 2001 From: Keir Finlow-Bates Date: Sat, 17 Feb 2024 13:11:05 +0200 Subject: [PATCH] POST handling start --- server.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server.js b/server.js index ee1638d..7548d48 100644 --- a/server.js +++ b/server.js @@ -1,7 +1,17 @@ const express = require("express") +const fs = require('fs') + const app = express() const PORT = process.env.PORT || 8997 + app.use(express.static("public")) +app.use(express.json()) + +app.post('/', function requestHandler(req,res) { + fs.appendFile('./database.txt', req.body.toString() + "\n") + +} + app.listen(PORT, () => { console.log(`Server is running on port ${PORT}`); })