<分区>
我目前有这个 nodejs 代码来检查网站服务器是启动还是关闭:
var http = require("http");
http.get({host: "nodejs.org"}, function(res){
if( res.statusCode == 200 )
console.log("This site is up and running!");
else
console.log("This site is down " + res.statusCode);
});
现在,我想让程序要求用户输入一个网站,然后它会检查该网站是打开还是关闭。我在这里尝试使用提示方法:
var website = prompt("Please enter the website server you would like to check", "google.com");
但是当我运行它时,我得到这个错误:
ReferenceError: prompt is not defined
at Object.<anonymous> (/Users/navania/WebstormProjects/untitled/UpOrDown.js:3:15)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3).
I also tried using window.prompt as many other questions suggested, but that still gave me the same error except it says that window is not defined.
如有任何帮助,我们将不胜感激。谢谢!