-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
42 lines (35 loc) · 987 Bytes
/
app.js
File metadata and controls
42 lines (35 loc) · 987 Bytes
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
36
37
38
39
40
41
42
'use strict'
// * 打印hello world
// * 定时打印hello world
// * 读取文件并输出
// * 自定关机
// * 创建一个服务器,记录访问次数
//使用控制台打印hello world
console.log('hello world');
// 定时打印hello world
// * 读取文件并输出
const fs = require('fs');
fs.readFile('./01_quick_start.js','utf8',(err,data)=>{
console.log(data);
});
// * 自定关机
const child_process = require('child_process');
// child_process.exec('shutdown -s -t 3600');
child_process.exec('shutdown -a');
// * 创建一个服务器,记录访问次数
const http = require('http');
let sum = 0;
let server = http.createServer((req,res)=>{
res.end('当前访问数量是'+ (++sum));
});
server.listen(80,()=>{
console.log('服务器启动了');
});
const http=require('http');
let sum=0;
let server=http.createServer((req,res)=>{
res.end('当前访问数量是'+(++sum));
});
server.listen(80,()=>{
console.log('服务器启动了');
});