Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const fs = require("fs")
- const app = express();
- var bodyParser = require("body-parser")
- app.use(bodyParser.urlencoded({extended:false}));
- app.use(bodyParser.json())
- app.get('/', (req, res) => {
- res.send(fs.readFileSync("test.txt",{"encoding":"utf-8"}))
- });
- app.post("/", function(req, res){
- fs.appendFile("test.txt",req.body)
- res.writeHead(200, {'Content-Type': 'text'});
- res.end('thanks');
- })
- app.listen(3000, () => {
- console.log('server started');
- });
Advertisement
Add Comment
Please, Sign In to add comment