Skip to content

Instantly share code, notes, and snippets.

@clamytoe
Last active August 29, 2015 14:27
Show Gist options
  • Save clamytoe/51343bfafc7eb2580acd to your computer and use it in GitHub Desktop.
Save clamytoe/51343bfafc7eb2580acd to your computer and use it in GitHub Desktop.
HKUSTx: COMP107x Introduction to Mobile Application Development using Android
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Setting up a Server on your Machine using NodeJS\n",
"---\n",
"\n",
"## Introduction\n",
"\n",
"For the next exercise and the assignment, you need to be able to access a server to download the JSON string and pictures. Here, we have provided you with instructions to set up a simple server on your own machine using NodeJS, a popular Javascript based server framework. To learn more about NodeJS, you can visit [https://nodejs.org](https://nodejs.org/).\n",
"\n",
"While teaching NodeJS is beyond the scope of this course, you can still learn more about NodeJS by directly contacting Dr. Muappala and he will give you further pointers.\n",
"\n",
"For this course, you just need to install NodeJS on your machine and fire up a server as per the instructions given on the Textual Instructions unit.\n",
"\n",
"## Textual Instructions\n",
"---\n",
"### Step 1: Installing NodeJS\n",
"\n",
"To install NodeJS on your machine, go to [https://nodejs.org](https://nodejs.org/) and click on the Install button. Depending on your computer's platform (Windows, MacOS or Linux), the appropriate installation package is downloaded. Follow along the instructions to install NodeJS on your machine.\n",
"\n",
"---\n",
"### Step 2: Downloading Server Configuration Files\n",
"\n",
"Download [server.zip](http://w02.hkvu.hk/edX/COMP107x/w5/server.zip) and unzip it at a convenient location on your machine. This will create a sub-folder named **server** on your machine that contains the configuration files for running a server on your machine. Move to this folder on your machine.\n",
"\n",
"---\n",
"### Step 3: Setting up JSON-Server\n",
"\n",
"1. Open a terminal window on your machine. If you are using a Windows machine, open a cmd window or PowerShell window with admin privileges.\n",
"2. To ensure that your NodeJS setup is working correctly, type the following at the command prompt to check for the version of **Node** and **NPM**.\n",
"\n",
" node -v\n",
"\n",
" npm -v\n",
" \n",
"3. At the command prompt type the following to install a simple JSON server package in NodeJS.\n",
"\n",
" npm install -g json-server\n",
"\n",
"Note: On MacOS and Linux you may need to add **sudo** in front of the command. When you are prompted by sudo, just type in your password in the window to proceed with the installation.\n",
"\n",
"---\n",
"### Step 4: Starting your Server\n",
"\n",
"1. To start your server, move to the server folder that you created by unzipping the configuration files above, then type the following at the command prompt.\n",
"\n",
" json-server --watch db.json\n",
"\n",
"2. To check that your server is running correctly and serving up the JSON string, type the url below into any browser window.\n",
"\n",
" http://localhost:3000/people\n",
"\n",
"3. Note down the **IP address** of your computer because you need to configure this in the code of the next exercise.\n",
"4. You can also cross-check by typing the url below into a browser window to ensure that your server is running correctly. This should show the JSON string in your browser window.\n",
"\n",
" http://<Your machine's IP address>:3000/people\n",
"\n",
"#### Finding your Machine's IP address\n",
"\n",
"1. If you are using a Microsoft Windows based machine, you can use the instructions available at [http://windows.microsoft.com/en-us/windows/find-computers-ip-address#1TC=windows-7](http://windows.microsoft.com/en-us/windows/find-computers-ip-address#1TC=windows-7) to find your machine's IP address.\n",
"2. On a Mac, go to System Preferences->Network to find the IP address of your network adapter."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment