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();
|
||||
Reference in New Issue
Block a user