Skip to content

Instantly share code, notes, and snippets.

@tjkhara
Last active November 11, 2020 13:08
Show Gist options
  • Select an option

  • Save tjkhara/cf7fe558f86d609c0d97296a100ed65f to your computer and use it in GitHub Desktop.

Select an option

Save tjkhara/cf7fe558f86d609c0d97296a100ed65f to your computer and use it in GitHub Desktop.
Complex App Note 1

Complex App Getting Started Note 1

Need to improve:

  1. Code organization
  2. Different users
  3. Attention to detail - validation

Create new folder

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment