Lo-Fi Python

Aug 09, 2017

Creating A Simple Website and Server Environment with Node.js and Express.js

Here is what I have deduced is the fastest way to get an app up and running with Node.js. This requires some familiarity with using the command line. I completed the Codeacademy course "Learn The Command Line" before beginning with Node.js. I think it helped me better understand what the commands are and what they do.

Download and install Node.JS Open the node command prompt. This was done on a windows machine.

First, create a folder for your app(s):

mkdir node_apps

Change the command prompt directory to your app's folder:
cd \app_name

Creates json file for your app. Fill out applicable info or just hit enter until the file is created.
npm init

Install express.js module in node.js:

npm install express

Install express-generator module in node.js:
npm install express-generator -g

Create the structure for your app and all necessary folders. (views, css, Javascript, routing, etc.)

express app_name

Ensure all app module dependencies are installed:

npm install

Start your server and web app:

npm start

Go to http://localhost:3000 in a browser. Port 3000 is the default port of Express. Your app is live in dev environment.

Notes

  • I learned most of this from this great blog post.
  • The above does not include a database integration. I integrated with a MongoDB database by following a blog post that has since been removed from the internet.
  • This YouTube video was also very helpful to me for figuring out MongoDB and Node.js integration.
  • An HTML shorthand language called jade (aka pug) comes stock within Express.js. Here's further reading on the pros and cons.
  • All of the above has been from my own studies. I do not claim anything listed as the most efficient or best way to use Node.js. This is what has worked for me over the past two days.
  • It feels good to whip up a nimble app environment that is capable of producing and supporting world changing software; Node.js is used by Netflix, PayPal, Microsoft and Uber.

Aug 05, 2017

Oversimplified Javascript Terms

I'm finally coming around in my understanding of Javascript. Here are a few quick explanations to help you if you are new to it.

Javascript = The language of the web. Most commonly used as a complement to HTML and CSS to create an interactive website.

JQuery = A popular Javascript library with many powerful commands that are quick and easy to call.

Node.JS = Software that allows you to run Javascript from the command line without being connected to the internet.

Express.JS = A popular Node.JS framework.

Angular = A popular front-end Javascript web framework. There are many out there but this seems to be the one I've heard of the most.

I've begun to see a pattern with programming languages:
1) Learn to execute the core building blocks. (using variables, loops, functions, etc.)
2) Learn more advanced libraries, documentation and uses.
3) Consider using and learning web frameworks depending on what you're trying to do with the language.
4) Practice to hone your knowledge. Build things you like.

I've also noticed that Javascript has been easier to learn than Python was for me, because it's not my first programming language. The concepts are the same. The syntax can trip me up at times, but I'm currently flying through Codeacademy's Javascript courses. Sometimes it even seems fun!