<commit_before>1. 'use strict';
2.
3. let http = require('http');
4.
5. http.createServer((request, response) => {
6. let fs = require('fs');
7. let postData = ''; // POST 資料
8.
9. // 利⽤ 'data' event 消耗掉 data chunk;
10. // 'end' event 才會被 fired
11. request.on('data', (chunk) =>
12. postData += chunk;
13.
14. console.log(
15. ' 接收的 POST data ⽚段 k: [' + chunk + '].'
16. );
17. });
18.
19. request.on('end', () => {
20. switch (request.url) {
21. case '/':
22. fs.readFile('../htdocs/index.html', (err, data) => {
23. if (err) {
24. console.log(' 檔案讀取錯誤');
25. }
26. else {
27. response.writeHead(200, {
28. 'Content-Type': 'text/html'
29. });
30.
31. response.write(data);
32. response.end();
33. }
34. });
35.
36. break;
37.
38. default:
39. console.log(' 未定義的存取: ' + request.url);
40.
41. response.end();
42.
43. break;
44. }
45. });
46. }).listen(8088);
47.
48. // log message to Console
49. console.log(' 伺服器啓動，連線 url: http://127.0.0.1:8088/');<commit_msg>11/3 0<commit_after>1. 'use strict';
2.
3. let http = require('http');
4.
5. http.createServer((request, response) => {
6. request.on('end', () => {
7. console.log('Request method: ' + request.method);
8. console.log('Request url: ' + request.url);
9. });
10.
11. // 傳送 HTTP header
12. // HTTP Status: 200 : OK
13. // Content Type: text/plain
14. response.writeHead(200, {
15. 'Content-Type': 'text/plain'
16. });
17.
18. // 傳送回應內容。
19. response.end('Hello World!\n');
20. }).listen(8088);
21.
22. // log message to Console
23. console.log('Server running at http://127.0.0.1:8088/');
{'fraction_non_alphanumeric': 0.23818770226537217, 'fraction_numerical': 0.1080906148867314, 'mean_word_length': 3.1117021276595747, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1946326', 'n_tokens_mistral': 732, 'n_tokens_neox': 676, 'n_words': 179}