Skip to content

Commit

Permalink
add html
Browse files Browse the repository at this point in the history
  • Loading branch information
zayidanil committed Aug 2, 2018
1 parent 8708321 commit 4497593
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
1 change: 1 addition & 0 deletions html1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>HALAMAN HTML 1</h1>
1 change: 1 addition & 0 deletions html2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>HALAMAN HTML PAGE 2</h1>
56 changes: 50 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,55 @@
var http = require('http');
var http = require('http');
var url = require('url');
var fs = require('fs');
var server = http.createServer(function(request, response) {
var path = url.parse(request.url).pathname;
switch (path) {
case '/':
response.writeHead(200, {
'Content-Type': 'text/plain'
});
response.write("This is Test Message.");
response.end();
break;
case '/html1.html':
fs.readFile(__dirname + path, function(error, data) {
if (error) {
response.writeHead(404);
response.write(error);
response.end();
} else {
response.writeHead(200, {
'Content-Type': 'text/html'
});
response.write(data);
response.end();
}
});
break;
case '/html2.html':
fs.readFile(__dirname + path, function(error, data) {
if (error) {
response.writeHead(404);
response.write(error);
response.end();
} else {
response.writeHead(200, {
'Content-Type': 'text/html'
});
response.write(data);
response.end();
}
});
break;
default:
response.writeHead(404);
response.write("opps this doesn't exist - 404");
response.end();
break;
}
});

var server = http.createServer(function(request, response) {

response.writeHead(200, {"Content-Type": "text/plain"});
response.end("WELCOME AT CBNCLOUD AZURE WORKSHOP!");

});

var port = process.env.PORT || 1337;
server.listen(port);
Expand Down

0 comments on commit 4497593

Please sign in to comment.