-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
37 lines (27 loc) · 862 Bytes
/
server.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
const express = require('express')
const app = express()
const path = require("path");
const pwd = process.cwd()
const port = 3000
const id = ["chair", "shoes"]
app.use('/data', express.static(pwd + '/data'));
app.use(express.static(path.join(__dirname, 'src')));
// app.use(express.static(path.join(__dirname, 'style')));
app.use('/style', express.static(pwd + '/style'));
for (let i of id) {
// app.use('/' , express.static(pwd + '/data'))
app.get(['/' + ':id'], (req, res) => {
res.sendFile(pwd + "/src/js/templates/index.html")
})
}
app.get('/', (req, res) => {
res.sendFile(__dirname + "/main.html");
})
// app.get('/', (req, res) => {
// res.sendFile(__dirname + "/src/home/index.html");
// })
app.listen(port, () => {
console.log(__dirname)
console.log(pwd)
console.log(`Example app listening at http://localhost:${port}`)
})