Javascript 未在node.js express上加载Css

Javascript 未在node.js express上加载Css,javascript,css,node.js,express,Javascript,Css,Node.js,Express,我正在使用node.js,express到一个天气应用程序,但是css没有加载,我确实遵循了这个链接 ,但到目前为止还没有成功,我确实在一个公共文件夹中有css html js //本地服务器已启动并正在运行 const express=要求(“express”); //节点内部请求 const https=require(“https”); 常量app=express(); //css 应用程序使用(express.static(uu dirname+“public”); 应用程序获取(“

我正在使用node.js,express到一个天气应用程序,但是css没有加载,我确实遵循了这个链接 ,但到目前为止还没有成功,我确实在一个公共文件夹中有css

html


js

//本地服务器已启动并正在运行
const express=要求(“express”);
//节点内部请求
const https=require(“https”);
常量app=express();
//css
应用程序使用(express.static(uu dirname+“public”);
应用程序获取(“/”,函数(请求,恢复){
const query=“利物浦”;
const apiKey=“3af2a1822cfe6d31e4317ac9c4b5d531”;
const unit=“公制”;
常量url=”https://api.openweathermap.org/data/2.5/weather?q=“+query+”&appid=“+apiKey+”&units=“+units;
https.get(url、函数(响应){
console.log(响应.状态码);
响应。关于(“数据”,函数(数据){
//将十六进制转换为js
const weatherData=JSON.parse(数据);
//询问我们想要的东西
常数温度=weatherData.main.temp;
const weatherDescription=weatherData.weather[0]。description;
const cityName=weatherData.name;
const icon=weatherData.weather[0]。图标;
常量imgURL=”https://openweathermap.org/img/wn/“+图标+”@2x.png”;
res.write(“当前天气为“+weatherDescription+”

”); res.write(“城市名称+”中的温度为“+数学圆(温度)+”摄氏度”); res.write(“”); res.send(); }) }); })
尝试清除缓存并硬重新加载。单击ctrl+shift+i,右键单击浏览器刷新按钮并选择第三个选项。

如何加载包含此
的HTML页面?是否也通过express服务器?控制台/网络中有错误吗?控制台中没有错误。很幸运,仍然是一样的,我将尝试复制项目,看看以后会发生什么
 <link rel="stylesheet" href="/css/style.css">

//local server up and running
const express = require("express");

//node internal request
const https = require("https");

const app = express();

//css
app.use(express.static(__dirname + "public"));

app.get("/", function (req, res) {

    const query = "Liverpool";
    const apiKey = "3af2a1822cfe6d31e4317ac9c4b5d531";
    const unit = "metric";
    const url = "https://api.openweathermap.org/data/2.5/weather?q=" + query +"&appid="+ apiKey + "&units=" + unit;

    https.get(url, function(response){
        console.log(response.statusCode);

        response.on("data", function(data){

            //convert hexadecimal to js
            const weatherData = JSON.parse(data);

            //asking the items that we want
            const temp = weatherData.main.temp;
            const weatherDescription = weatherData.weather[0].description;
            const cityName = weatherData.name;
            const icon = weatherData.weather[0].icon;
            const imgURL = "https://openweathermap.org/img/wn/" + icon + "@2x.png";

            res.write("<p>The weather is currently " +weatherDescription + "</p>");
            res.write("<h1>The temperature in " + cityName + " is " + Math.round(temp) + " degree Celsius</h1>");
            res.write("<img src=" + imgURL + ">");

           res.send();
        })
    });
})