-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
71 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,17 @@ | ||
// Outputs "Hello World" to the console | ||
console.log("Hello World"); | ||
console.log("Hello World"); | ||
|
||
// Variables + math operation | ||
var number = 1; | ||
number = number + 1; | ||
number += 1; | ||
console.log(number); | ||
|
||
// Strings | ||
var text; | ||
text = "How are you doing"; | ||
console.log(text); | ||
|
||
// Adding strings, and "variable type" changing | ||
text = text + 2; | ||
console.log(text); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
// Outputs "Hello World" to the console | ||
console.log("Hello World"); | ||
// Raw example expand | ||
|
||
|
||
function text(phrase) { | ||
console.log(phrase); | ||
} | ||
|
||
function myFunction(someFunction, value) { | ||
someFunction(value); | ||
} | ||
|
||
myFunction(text, "Hi"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
// Outputs "Hello World" to the console | ||
console.log("Hello World"); | ||
// "require" is Node.js feature to "load" libraries | ||
// Library is loaded into variable "http" | ||
var http = require("http"); | ||
|
||
// Starts a server, takes in a function as an argument | ||
http.createServer(function (req, res) { | ||
|
||
// If someone visits the webpage, it returns a webpage with the words "Hello world" | ||
res.writeHead(200, {"Content-Type": "text/plain"}); | ||
res.end("This is my website\n"); | ||
|
||
// Have server listen on port "1337" | ||
}).listen(1337, "127.0.0.1"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Use NPM to install expressjs | ||
//npm install express | ||
|
||
// Set express module to variable "express" | ||
var express = require('express'); | ||
|
||
// Create an "app" variable from the express library | ||
var app = express(); | ||
|
||
// Add a "route" that leads to the req/res, as seen in Node.js | ||
app.get('/', function(req, res){ | ||
res.send("Express powered web page"); | ||
}); | ||
|
||
// Starts up the server | ||
var server = app.listen(1337, function() { | ||
|
||
}); |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
// Outputs "Hello World" to the console | ||
console.log("Hello World"); | ||
// Load the TCP library and assign it to variable "net" | ||
var net = require("net"); | ||
|
||
// Start the TCP server | ||
var server = net.createServer(function (socket) { | ||
// If someone connects to the server, just repeat the message | ||
socket.write("You said: \r\n"); | ||
socket.pipe(socket); | ||
}); | ||
|
||
// Have the TCP server listen to port 1337 | ||
server.listen(1337, "127.0.0.1"); |