在Node.js中显示检索到的aws实例到HTML页面
我有一个代码从aws中检索实例
var aws = require('aws-sdk'); aws.config.update({ accessKeyId: 'YOUR_ACCESS_KEY', secretAccessKey: 'YOUR_SECRET_KEY', region: 'us-west-2' }); var ec2 = new aws.EC2(); function printStatuses() { ec2.describeInstances({}, function(err, data) { if(err) { console.error(err.toString()); } else { var currentTime = new Date(); console.log(currentTime.toString()); for(var r=0,rlen=data.Reservations.length; r<rlen; r++) { var reservation = data.Reservations[r]; for(var i=0,ilen=reservation.Instances.length; i<ilen; ++i) { var instance = reservation.Instances[i]; var name = ''; for(var t=0,tlen=instance.Tags.length; t<tlen; ++t) { if(instance.Tags[t].Key === 'Name') { name = instance.Tags[t].Value; } } console.log('\t'+name+'\t'+instance.InstanceId+'\t'+instance.PublicIpAddress+'\t'+instance.InstanceType+'\t'+instance.ImageId+'\t'+instance.State.Name); } } } }); }
上面的代码工作正常,它检索实例并显示在terminal中,我想在前面的视图中显示在HTML页面上。 我已经开发了前端页面,并希望实例出现在此页面(在表格标签内)而不是控制台。
front end html code <!DOCTYPE html> <html> <head> <script type="text/javascript"> </script> <meta charset="ISO-8859-1"> <style> th {background-color:lightgrey; } h1 {color:blue; text-align:center;} p {color:blue; text-align:left;} </style> </head> <body> <form action="/" method="post"> <table width="100%" border=1> <tr> <th>Instances</th> <th>Status</th> <th>Start/Stop</th> </tr> <tr> <td id="instance"></td> <td id="status"></td> <td> <button id='start'>start</button> <button id='stop'>stop</button></td> </tr> </table> </body> </html>
- 将rds上的postgresql连接到节点js服务器
- nodejs – cassandra-client错误:所有连接都不健康
- 在AWS上使用Rserve在Node.js和R之间进行跨平台通信时出错。 错误:连接ETIMEDOUT
- 我如何在亚马逊ec2服务器上find我的Nameservers?
- node.js与Linux上的下划线错误:找不到模块“下划线”
- 什么可能会阻止EC2托pipe的机器人在Microsoft Bot Framework上回复消息?
- 如何在端口80上运行“Deployd”,而不是在Web服务器上运行端口5000。
- 在AWS EC2上安装NPM
- 丢失Amazon Ec2服务器上的数据库连接