Giter Club home page Giter Club logo

artes-docendi's Introduction

How to set up basic app

Introduction

For those who are trying out programming for the first time, here are some words of clarification about the instructions below.

  • These instructions assume you are using a Mac. I will try to add Windows instructions at some point.
  • Whenever you see text written like this, that means it is a command to be typed into your computer's terminal.
    • To open the terminal, press Command + Space and type "terminal" then press ENTER.
    • Whenever you see {{something in braces}}, that means you should replace {{the thing in braces}} with some value that makes sense in the context. For example, if you see something like "Create a directory called {{YOUR_APP_NAME}}", you would want to create a directory called whatever you intend to call your app.
  • Useful terminal commands

Install Software

  1. Install node then run the command sudo npm install npm -g
  2. Install Sublime to use as a text editor

Set Up Your Workspace & App Folder

  1. Create a folder to hold your programming projects: mkdir ~/Workspace
  2. Navigate into your workspace folder: cd ~/Workspace
  3. Create a folder for your app: mkdir {{YOUR_APP_NAME}}
  4. Navigate into your new app folder: cd {{YOUR_APP_NAME}}
  5. Create a file that will "serve" your website (more on this soon): touch server.js
  6. Install express (this is a node module your server will use): npm install express
  7. Create a folder to hold the files that will make up your web site: mkdir app
  8. In the app folder, create your main html page: cd app && touch index.html

Enter Some Code

  1. Open your app folder in Sublime
  • Start Sublime then click File - Open, select your app folder, then press Open
  1. Add the following code to server.js:
var express = require('express'),
    app = express();

app.use(express.static('app'));

var server = app.listen(3000, function () {
  var host = server.address().address,
      port = server.address().port;
  console.log('Server listening at ' + host + ':' + port);
});
  1. Add the following code to index.html:
<!doctype html>
<html>
  <body>
    <h1>Hello, World</h1>
  </body>
</html>

Start the server

  1. Navigate to the "root" directory of your app:
  • If you are in the ~/Workspace directory, you can type cd {{YOUR_APP_NAME}} to get into ~/Workspace/{{YOUR_APP_NAME}}
  • If you are in the ~/Workspace/{{YOUR_APP_NAME}}/app directory, you can type cd .. to go back one level to ~/Workspace/{{YOUR_APP_NAME}}
  • If you are not sure where you are, simply type cd ~/Workspace/{{YOUR_APP_NAME}}
  1. Type node server.js to start the server
  2. In your web browser, navigate to http://localhost:3000, and you should see your Hello World message

artes-docendi's People

Contributors

magistrula avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.