-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
40 lines (29 loc) · 848 Bytes
/
app.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
const express = require('express')
const bodyParser = require('body-parser');
const ejs = require('ejs');
const app = express()
const port = 3000
app.use(bodyParser.urlencoded({ extended: true }));
app.engine('ejs', ejs.renderFile);
function test(req, res) {
res.send('Hello World!')
}
app.get('/', test)
app.get('/form.html',(req,res)=> {
res.sendFile(__dirname + '/form.html')
})
app.get('/test.html',(req,res)=> {
res.sendFile(__dirname + '/test.html')
})
app.get('/target1', (req, res) => {
res.send('Hello' + req.query.namehoge);
});
app.post('/target1', (req, res) => {
res.send('Hello' + req.body.namefuga);
});
app.post('/target2', (req, res) => {
res.render(__dirname + '/target2.ejs', { gggg: req.body.gggg});
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})