-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
62 lines (41 loc) · 1.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const express = require('express')
const app = express()
const port = 3000
app.use(express.static(__dirname));
app.use(express.static('public'));
app.use(express.static('files'));
const bodyparser = require('body-parser');
const fs = require('fs');
const jsonParser= express.json()
app.use(bodyparser.urlencoded({extended:true}));
app.post("/",(req, res) => {
let userReg = {name: req.body.uname, email: req.body.email, psw: req.body.psw};
res.send(userReg)
try{
const arr = require('./5% json.json');
arr.push(userReg);
fs.writeFile('./5% json.json',JSON.stringify(arr,null,2),err=>{
if(err){
console.log(err);
}
else{
}
})
}
catch (err){
console.log(err)
return
}
})
app.get('/', (req, res) => {
res.sendfile('index.html')
})
app.get('/styles_of_swimming', (req, res) => {
res.sendfile(__dirname + '/styles/styles.html')
})
app.get('/muscle', (req, res) => {
res.sendfile('musclest.html')
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})