[英]express.static not rendering the CSS file i have attached to html content, i am using Ubuntu
[英]how can i bring html file in my nodejs file using express static at ubuntu?
const express =require('express');
const app= express();
const morgan= require('morgan');
const mysql= require('mysql');
//const path= require('path')
app.use(express.static('pub'));
在 ubuntu 我的 app.js 文件在 /home/ubuntu/u 和 form.html 文件在 /home/ubuntu/u/pub
所以我想在 app.js 中使用 form.html 文件,但我只能得到:
::ffff:175.194.23.67 - - [23/Jan/2020:16:23:07 +0000] "GET / HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
(此消息來自終端)。
我嘗試使用__dirname
或static
但它們沒有用。 我的代碼有什么問題?
請試試這個
app.use(express.static(`${__dirname}/pub`));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.