-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
59 lines (49 loc) · 1.41 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const express = require('express')
const app = express()
const path = require('path')
var port = process.env.PORT || 8080;
// views
const views = path.join(__dirname, 'views/')
// public
const public = path.join(__dirname, 'public/')
// hhtp routes
const httpRaiz = '/'
const httpHome = '/home'
const httpRegister = '/register'
const httpLogin = '/login'
const httpHomeLogin = '/homelogin'
const httpFlexBox = '/flexbox'
const httpPosition = '/position'
// html
const homeHtml = 'home.html'
const registerHtml = 'register.html'
const loginHtml = 'login.html'
const flexBoxHtml = 'flexbox.html'
const positionHtml = 'position.html'
// Define the static file path
app.use(express.static(__dirname +'/public/'));
app.get(httpRaiz, (req, res) => {
res.sendFile(path.join(views, homeHtml))
})
app.get(httpHome, (req, res) => {
res.sendFile(path.join(views, homeHtml))
})
app.get(httpRegister, (req, res) => {
res.sendFile(path.join(views, registerHtml))
})
app.get(httpLogin, (req, res) => {
res.sendFile(path.join(views, loginHtml))
})
app.post(httpHomeLogin, (req, res) => {
res.sendFile(path.join(views, loginHtml))
})
app.get(httpFlexBox, (req, res) => {
res.sendFile(path.join(views, flexBoxHtml))
})
app.get(httpPosition, (req, res) => {
res.sendFile(path.join(views, positionHtml))
})
app.listen(port, () => {
console.log(`App listening at http://localhost:${port}`)
console.log(__dirname)
})