Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5d928ff

Browse files
committed
added week1 template
1 parent a74cc2a commit 5d928ff

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

week1/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## This week homework
2+
3+
Assignment:
4+
Create a http server that listens to requests
5+
http://localhost:8080/status -->
6+
http://localhost:8080/add -->
7+
http://localhost:8080/subtract -->
8+
9+
Reading
10+
Callbacks
11+
modules, require
12+
http, http listen
13+
refresh on command line

week1/index.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var http = require('http');
2+
3+
var port = 8080;
4+
var host = '0.0.0.0';
5+
6+
var server = http.createServer();
7+
8+
// Start the HTTP server, start listening for requests
9+
server.listen(port, host, function(error) {
10+
if (error) {
11+
console.log(error);
12+
} else {
13+
console.log('api listening on port', port);
14+
}
15+
});
16+
17+
// Create a event handler for "request"
18+
server.on('request', function(request, response) {
19+
console.log('New http request received', request.url);
20+
response.write('<html><head></head><body><h1>Hello world</h1></body></html>');
21+
response.end();
22+
});
23+

week1/package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "week1",
3+
"version": "1.0.0",
4+
"description": "Week 1 homework",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/HackYourFuture/Node.js.git"
12+
},
13+
"keywords": [
14+
"nodejs"
15+
],
16+
"author": "Erol",
17+
"license": "ISC",
18+
"bugs": {
19+
"url": "https://github.com/HackYourFuture/Node.js/issues"
20+
},
21+
"homepage": "https://github.com/HackYourFuture/Node.js#readme"
22+
}

0 commit comments

Comments
 (0)