Skip to content

Commit 10acaee

Browse files
committed
nicer example files
1 parent 9c8820b commit 10acaee

File tree

6 files changed

+71
-5
lines changed

6 files changed

+71
-5
lines changed

assets/favicon.ico

32.5 KB
Binary file not shown.

assets/favicon.svg

Lines changed: 11 additions & 0 deletions
Loading

assets/style.css

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
html, body{
2+
font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
3+
font-size: 16px;
4+
line-height: 1.3em;
5+
background: #fafbfc;
6+
}
7+
.cont{
8+
width: 700px;
9+
padding: 50px;
10+
margin: 20px auto;
11+
background: #fff;
12+
overflow:hidden;
13+
border: 1px solid #eee;
14+
}
15+
.cont img{
16+
float: left;
17+
}
18+
.cont .texts{
19+
float: left;
20+
margin-left:25px;
21+
}
22+
.cont .texts h1{
23+
font-weight:normal;
24+
font-size: 200%;
25+
line-height: 1.3em;
26+
margin: 0 0 10px 0;
27+
}
28+
.cont .texts p{
29+
margin: 5px 0;
30+
}
31+
.cont .texts pre,
32+
.cont .texts code{
33+
margin: 5px 0;
34+
}

dynamic-content/index.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var fs = require('fs');
2+
13
var App = function (httpServer, expressServer, sessionParser, request, response) {
24
this._init(httpServer, expressServer, sessionParser, request, response);
35
};
@@ -13,9 +15,20 @@ App.prototype = {
1315
httpRequestHandler: function (request, response, callback) {
1416
this._completeWholeRequestInfo(request, function (requestInfo) {
1517

16-
response.send('hallo world! (' + requestInfo.url + ')');
1718

18-
callback();
19+
20+
var staticHtmlFileFullPath = __dirname + '/../static-content/index.html';
21+
fs.readFile(staticHtmlFileFullPath, 'utf8', function (err,data) {
22+
if (err) {
23+
console.log(err);
24+
return callback();
25+
}
26+
response.send(data.replace(/%requestPath/g, requestInfo.url));
27+
callback();
28+
});
29+
30+
31+
1932
}.bind(this));
2033
},
2134
_completeWholeRequestInfo: function (request, callback) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "web-dev-server/example-helloworld",
2+
"name": "web-dev-server-example-helloworld",
33
"version": "1.0.0",
44
"description": "Hallo world example with static and dynamic content.",
55
"homepage": "https://github.com/web-dev-server",

static-content/index.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22
<html lang="en-US">
33
<head>
44
<meta charset="UTF-8">
5-
<title></title>
5+
<title>Web Development Node.js Server</title>
6+
<link rel="stylesheet" href="../assets/style.css" />
67
</head>
78
<body>
8-
<h1>Hallo world!</h1>
9+
<div class="cont">
10+
<img src="../assets/favicon.svg" width="100" height="100" alt="Web Development Node.js Server" />
11+
<div class="texts">
12+
<h1>Web Development Node.js Server</h1>
13+
<p>Node.js simple http server for common development or training purposes.</p>
14+
<pre><code>%requestPath</code></pre>
15+
</div>
16+
</div>
917
</body>
1018
</html>

0 commit comments

Comments
 (0)