Saturday 27 April 2019

Express not applying css or scripts

I'm linking a css file to my express-handlebars file but I am getting this error:Refused to apply style from 'http://localhost:4000/cs366/style/draft.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.GET http://localhost:4000/cs366/JS/draft.js net::ERR_ABORTED 404 (Not Found)I have the static directory set, and my css and script files are being applied and loaded in home.handlebars, but not fantasyDraft.handlebarsMy file directoryproject |-- public | `-- style | |-- home.css | `-- draft.css |-- Fantasy | `-- fantasyRouting.js |-- views | |-- fantasyDraft.handlebars | `-- home.handlebars |-- app.js `-- connect.js App.jsconst express = require('express'); var exphbs = require('express-handlebars'); const db = require('./connect'); //connnect to db const path = require('path'); const app = express(); //middleware app.use(express.urlencoded({extended: false})); //static folder app.use(express.static(path.join(__dirname, '/public'))) //handlebars middleware app.engine('handlebars', exphbs({defaultLayout: null})); app.set('view engine', 'handlebars'); //home app.get('/cs366', (req, res) => { res.render('home'); }); //fantasy app.use('/cs366/fantasy/start', require('./fantasy/fantasyRouting')); fantasyRouting.JS - Handles the routes for a part of the application to avoid clutter in app.jsconst express = require('express'); const router = express.Router(); router.post('/', (req, res) => { players = [ { id: 1, name: 'Alex Johnson', position: 'p10', ovr: 60 }, { id: 2, name: 'Carl Erdman', position: 'p2', ovr: 76 }, { id: 3, name: 'Joe Enslin', position: 'p1', ovr: 29 } ] res.render('fantasyDraft', { players: players }); }); module.exports = router; fantasyDraft.handlebars

Drafting

Name OVR Postion
Name OVR Postion
home.handlebars

CS-366 Soccer

stuff



Submitted April 27, 2019 at 06:45PM by Ce-Jay

No comments:

Post a Comment