以下是我的代码,但没有工作,我包括CSS& JS在html中以正确的方式进行,但它还不包括下面的截图。
节点Js代码:
var ejs = require('ejs');
var pg = require('pg');
var path = require ('path');
var bodyParser = require('body-parser');
var mysql = require('mysql');
/* Database connectivity */
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "training.com"
});
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(__dirname + '/assets'));
app.get('/',function(req,res,next){
res.sendfile('user-profile-edit.html');
});
app.post('/', function(req, res){
console.log('req.body');
console.log(req.body);
var nme= req.body.name;
var eml= req.body.email;
var drs= " Sucessfully Inserted ";
});
app.listen(8080);
console.log('My Current port:8080');
ScreenShot:http://prntscr.com/fds2ee
答案 0 :(得分:0)
为静态文件夹指定一个相对路径,如/assets
:
app.use('/assets',express.static(path.join(__dirname, 'assets')));
在你html
<link href="/assets/libraries/font-awesome/css/font-awesome.min.css" rel='stylesheet' type='text/css'>