upload all files
This commit is contained in:
38
Modules/example/getAddr/app.js
Normal file
38
Modules/example/getAddr/app.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const http = require('http');
|
||||
const httpPort = 8766;
|
||||
|
||||
const data = JSON.stringify({
|
||||
cmdType: 'getAddr',
|
||||
addrType: 'server.main'
|
||||
});
|
||||
|
||||
const options ={
|
||||
hostname: 'localhost',
|
||||
port: httpPort,
|
||||
path: '/',
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': Buffer.byteLength(data)
|
||||
}
|
||||
}
|
||||
|
||||
const req = http.request(options, (res) => {
|
||||
console.log(`Status code: ${res.statusCode}`);
|
||||
|
||||
let responseData = '';
|
||||
res.on('data', (chunk) => {
|
||||
responseData += chunk;
|
||||
});
|
||||
|
||||
res.on('end', () => {
|
||||
console.log(`Response data: ${responseData}`);
|
||||
});
|
||||
});
|
||||
|
||||
req.on('error', (error) => {
|
||||
console.error(`Error: ${error.message}`);
|
||||
});
|
||||
|
||||
req.write(data);
|
||||
req.end();
|
||||
12
Modules/example/getAddr/package.json
Normal file
12
Modules/example/getAddr/package.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "getaddr",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
Reference in New Issue
Block a user