Utilizing ejs, express, and parse.com for my web application backend has presented a challenge when it comes to adding stylesheets. Despite searching for solutions, I have not been able to resolve the issue. Sharing my code in hopes of finding a solution.
Displayed below is an excerpt from cloud/app.js:
var express = require('express');
var app = express();
app.use(express.static(__dirname + '/public'));
app.set('views', 'cloud/views'); // Specify the folder to find templates
app.set('view engine', 'ejs'); // Set the template engine
app.use(express.bodyParser()); // Middleware for reading request body
var Movies = Parse.Object.extend('Movies');
app.get('/', function(req, res) {
var query = new Parse.Query(Movies);
query.find({
success: function(results) {
res.render('movie-list', { movies: results });
},
error: function(results, error) {
}
});
});
app.listen();
In addition, here is the template located in the views directory:
<html>
<head>
<title>Movies</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" type="text/css">
</head>
<body>
<h1>Movies</h1>
<ul id="categoryList" class="list-group">
<%
for (var i = 0; i < movies.length; i++)
{
var movie = movies[i];
%>
<li class="list-group-item"><%= movie.get('Movie')%></li>
<%
}
%>
</ul>
</body>
</html>
Your assistance on this matter would be highly appreciated. Many thanks!