bio photo

Email

Week 2 class notes

"npm install"

installs all libraries in package.json

Express handles:

  • Routing (very basic thing for a website. When browser hits a URL it routes the code to the right spot)

  • res.render (render is coming from the folder called “views”)

  • Rendering template called “home”, which is from handlebars (home.handlebars)

  • Template is just where we store all the HTML code.

  • It doesn’t default to home.handlebars, default is main.handlebars!

  1. Handlebar is a template language. It’s considered bad form to write a lot of logic in the HTML. In handlebars, “if there’s a variable called name… run that logic”

  2. When we render home, we are rendering it in main. In main.handlebars: there’s { { body } }, which just sucks in everything from home.handlebars. <- we dont know where nomenclature from body comes from

  3. Bootstrap is a set of CSS, to make websites. Getbootstrap.com.

  4. GET -> I want to get something from the server. GIVE ME THE INFORMATION.

  5. POST -> TAKE something that I want to give to the server.

message: req.body.message 

-> take it from bodyParser

res.render 

these are “middlewares” in Express library.

app.use(bodyParser.urlencoded({ extended: true }));  

is telling app, before we get any of our request, hand it to bodyParser, in this case, it will populate req.body.message.

We are not storing this data, just posting it and then it disappears. We are not storing it into a cookie, or any database.

var values = {
	pageTitle: "submit new task"
	message: req.body.message
}

Those things that are on the left side of the name : key values, you dont need to define them. BUT ON THE RIGHT (keys) you have to define (as var or whatever) OR quote them.

  1. This is also some code
var foods = [
	{name: 'beans',
	organic: "yes",
	},

	{name: 'Pickles',
	 organic: "no"},
	];
	console.log(req.body.title);
    res.render('list', { Myfoods: foods, pageTitle: "My Favorite Foods" } );
});
foods

are the values we’re passing to Myfoods (the keys). Myfoods, the key is being called elsewhere in the code, in list.handlebars more specifically:

<ul>
   { {#each Myfoods}}
     <li> { { this.name } } (organic?: )
   { { /each } }
</ul>
 #each 

is a foor loop - FOR EACH Myfoods value, <li> it. Keep looping it again and again. An if statement (in first week homework), it just goes through once. #each (or for-each Myfoods) it loops over and over again.

Market Places

Below are the metrics we are comparing various marketplaces against.

  • Need vs Luxury
  • Virtual vs Physical
  • Service vs Product (Human Capital vs )
  • Skilled vs UnSkilled
  • Sharing Existing (what you have) vs New
  • Subscription vs Transaction
  • Immediate (Uber, right now) vs Planned (Airbnb, tomorrow)
  • Some are for work, others are for home
  • Convenience
  • Want it right now, but not everyday. Subscription vs On-demand.
  • Physical services of non-skilled laborers sharing jobs done transactionally for immediate luxury personal or work needs.

Here they are plotted on a graph