我正在尝试将css表包含在我简单的html页面中。 我使用parse.com托管来托管使用express的动态网页。
这个问题有很多答案,但似乎没有一个对我有用。
我正在尝试使用这行代码
从我的.ejs页面中包含我的css文件<link rel="stylesheet" type="text/css" href="css/content.css" />
我在公共floder中复制了我的css文件夹
建议最多的答案是添加以下代码:
app.use(express.static(__dirname + '/public'));
但它不起作用。
var express = require('express');
var app = express();
app.use(express.static(__dirname + '/public'));
// Global app configuration section
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
// This is an example of hooking up a request handler with a specific request
// path and HTTP verb using the Express routing API.
app.get('/content/:id', function(req, res) {
res.render('content', {message: "hi"});
});
我按照本指南设置快递: https://www.parse.com/docs/hosting_guide#webapp-started
当我尝试部署我的代码时,我收到此错误“更新失败并且无法加载触发器。错误是ReferenceError:__dirname未定义”
我在这里做错了什么?
答案 0 :(得分:0)
在考虑这个问题一段时间后,我在parse.com网站上看到了这个。
"our Express app can sit side-by-side with any static content you deployed from your public folder. When a request goes to a URL of your subdomain, Parse will first look for a matching file in the public directory. If there is no match, then Parse will invoke any Express request handlers that you have registered in Cloud Code. If there is still no match, Parse will render a "404 Not Found" page."