nodejs httpserver

1
touch time.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var http = require("http");
var sleep = require('system-sleep');


var server = http.createServer(function (req, res) {
var requestBody = "";
req.on('data', function(chunk) {
requestBody += chunk;
});

req.on('end', function() {
var request = req.method + " " + req.url + "\n\n";

var hrTime = process.hrtime();
request += (hrTime[0] * 1000000 + hrTime[1] / 1000);
request += "\n\n";

res.setHeader('Content-Type', 'application/json');
res.setHeader('X-QUOTA', '100');
res.setHeader('Access-Control-Allow-Origin','*');

if (req.url != "/") {
console.log(request);
}
if (req.url != "/no-end-response"){
res.end(request);
}
});

req.on('error', function(err) {
console.log(err);
});
});
server.listen(9999);
server.timeout = 400000
1
2
touch run_time_server.sh

1
2
3
4
#!/bin/sh

pkill node
node --max-old-space-size=2048 time.js &
1
2
## run time server
./run_time_server.sh

img.png

参考文章

http-server

1
npm install --global http-server
1
http-server --proxy http://localhost:8080?
阅读更多

hexo_guide

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

install

1
npm install -g hexo-cli hexo

Quick Start

1
hexo clean && hexo g && hexo server

Create a new post

1
$ hexo new "My New Post"
阅读更多

hexo icarus

install

1
2
3
4
5
6
# cd /d/WorkPlace/myHexo
# git clone https://github.com/ppoffice/hexo-theme-icarus.git themes/icarus
git clone git@github.com:luochunhai/my_hexo_icarus.git themes/icarus

npm install hexo-theme-icarus
hexo config theme icarus
阅读更多