Need to improve:
- Code organization
- Different users
- Attention to detail - validation
new file app.js npm init -y npm install express
Import this into the file
let express = require('express')
const app = express()
app.get('/', function(req, res){
res.send('Welcome to our new app')
})
app.listen(3000)
node app
Check out the site in the browser
Get the html from the link
home-guest.html
Create new folder - views
In views create home-guest.ejs
Paste the html
Add this line in app.js
app.set('views', 'views')
Add this above the first app.get function
Template engine
app.set('view engine', 'ejs')
npm install ejs
Change line
res.render('home-guest')
Restart server and check page
Set up CSS:
create new folder public
app.use(express.static('public'))
Get CSS file - main.css
main.css inside public
in home-guest.ejs put / in front of main.css
Check the app in browser
Automatic restart -
npm install nodemon
package.json in scripts "watch":"nodemon app",
npm run watch