Skip to content

Instantly share code, notes, and snippets.

@jsstoni
Last active August 29, 2015 14:14
Show Gist options
  • Save jsstoni/b5bfe99766fcfaff9dc9 to your computer and use it in GitHub Desktop.
Save jsstoni/b5bfe99766fcfaff9dc9 to your computer and use it in GitHub Desktop.
problema con rutas get
var express = require('express'),
url = require('url'),
path = require('path'), app = module.exports = express();
app.engine('.html', require('ejs').__express);
app.set('views', __dirname + '/views');
app.set('view engine', 'html');
var menu = [
{titulo : 'Sobre Nosotros', link : 'about'}
];
app.get('/', function(req, res) {
res.render('index', {menuNav : menu});
});
app.get('/cursos/:id', function(req, res) {
//console.log(req.params.id);
req.url = '/';
res.render('cursos', {menuNav : menu});
});
app.use('/public/imagen',express.static(path.join(__dirname, 'public/imagen')));
app.use('/public/fonts',express.static(path.join(__dirname, 'public/fonts')));
app.use('/public/css',express.static(path.join(__dirname, 'public/css')));
app.listen(80);
@andarms
Copy link

andarms commented Feb 5, 2015

en vez de usar 3 app.use para declarar las rutas de los archivos estaticos, usa solo una de esta forma:

app.use(express.static(__dirname + '/public'));

y desde el html solo llamas:

<link rel="stylesheet" href="css/style.css">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment