-
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
1 parent
c4a46e8
commit 1848365
Showing
4 changed files
with
52 additions
and
0 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
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,3 @@ | ||
body {background-color: powderblue;} | ||
h1 {color: blue;} | ||
p {color: red;} |
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,9 @@ | ||
<html> | ||
<head> | ||
<title>Page HTMl </title> | ||
<link rel="stylesheet" href="styles.css"> | ||
</head> | ||
<body> | ||
This is node js test page.html | ||
</body> | ||
</html> |
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,25 @@ | ||
var http = require('http'); | ||
var fs = require('fs'); | ||
|
||
http.createServer(function (req, res) { | ||
var content = ''; | ||
var type = ''; | ||
|
||
if(req.url === '/') { | ||
content = fs.readFileSync('./page.html'); | ||
type = 'text/html'; | ||
} else if(req.url === '/styles.css') { | ||
content = fs.readFileSync('./assets/style.css'); | ||
type = 'text/css'; | ||
} else if(req.url === '/api/user/new') { | ||
// Do action | ||
// POST parameter | ||
// save to db | ||
content = '{"success": true}'; | ||
type = 'application/json'; | ||
} | ||
|
||
res.writeHead(200, {'Content-Type': type}); | ||
res.end(content + '\n'); | ||
}).listen(1337, '127.0.0.1'); | ||
console.log('Server running at http://127.0.0.1:1337'); |