const http = require('http');
function gethttp(router,url) {
var port = 0;
if (router == 'ap') port = порт ap;
if (router == 'ap-tvix') port = порт ap-tvix;
if (port > 0) {
const options = {
host: 'cholv.ru',
headers: {Authorization: 'Basic code'},
port: port,
path: url
};
return new Promise((resolve, reject) => {
http.request(options, (response) => {
let data = '';
response.on('data', (chunk) => {
data += chunk;
});
response.on('end', () => {
resolve(data);
});
response.on('error', (err) => {
reject(err);
});
}).end();
});
}}
module.exports.handler = async function (event, context) {
let str = await gethttp('ap-tvix','/status');
return(str);
};
|