我正在嘗試測試一個簡單的 javascript 文件,但無法在我的瀏覽器上進行測試,因為該頁面會在沒有任何警告的情況下永久加載,并且在底部出現(xiàn)一個文本欄,上面寫著“等待本地主機 ...” 在 bash 上,我正在輸入節(jié)點 app.js 并在按預(yù)期輸入終端后顯示“服務(wù)器已啟動”,但是當我轉(zhuǎn)到“http://localhost:3000”時,頁面將永遠加載。我已經(jīng)安裝了節(jié)點并正確表達。(我無法在此處包含 express,因為我不知道該怎么做。)請客氣,我是開發(fā)世界的新手。// Express Setuplet express = require("express");let app = express();// Setting Up Routesapp.get("/",function(req,res) { res.send = "Hi There, Welcome To My Assignement!";});app.get("/:actionName/pig", function(req , res){ res.send = "The Pig Says \"Oink\" !";});app.get("/:actionName/dog", function(req , res){ res.send = "The Dog Says \"Woof\" !";});app.get("/:actionName/cow", function(req , res){ res.send = "The cow Says \"Moo\" !";});app.get("/repeat/:string/:times",function(req,res){ let times = parseInt(app.param.times); for (let i = 0 ; i <= times ; i++) { res.send = app.param.toString; }});app.get("*" , function(req,res){ res.send = "Error 404, Page not found!";});// Setting Port Upapp.listen(3000, function () { console.log("Server Has Started!");});
節(jié)點服務(wù)器本地主機問題
阿波羅的戰(zhàn)車
2022-10-13 19:41:49