How to check if the EJS is responding

2

My application is node with express and ejs

1 - It is running index.html and not index.ejs 2 I am not able to pass the title or title parameter to the view, neither in ejs nor in html

app.js and index.ejs look like this:

var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

var index = require('./routes/index');
var users = require('./routes/users');

var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', index);
app.use('/users', users);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
  var err = new Error('Not Found');
  err.status = 404;
  next(err);
});

// error handler
app.use(function(err, req, res, next) {
  // set locals, only providing error in development
  res.locals.message = err.message;
  res.locals.error = req.app.get('env') === 'development' ? err : {};

  // render the error page
  res.status(err.status || 500);
  res.render('error');
});

module.exports = app;

No index.ejs it's like this

<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="!utf-8">
    <meta name ="viewport" content="width-device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie-edge">
    <link rel="stylesheet" href="stylesheets/boxstyle.css"
    <title> Index.ejs node.js web server </title>
    </head>
    <body>
    <!-- <body background="./images/fundo004.png"> -->
    <br>
    <h1> EJS no Servidor Node.js </h1>
    <h2> <%= $title %></h2>
    <br>
    <p>&nbsp;&nbsp;Bem vindo ao portal FullTime Tecnology!<p>
  <br>
  <br>
  <br>
  <br>
  <br>

    <br>
        Desenvolvimento de Sistemas.
    <br>
        Projeto de Infraestrutura em redes de dados.
    <br>
        Especificação de Equipamentos Técnicos.
    <br>
        Pesquisa Científica em Soluções de Comunicação em Tempo Real.
    <br>

  <p><a href="https://www.facebook.com/Felipe1964">Novo site! Visite FullTime.com!</a></p>

  </body>
</html>
    
asked by anonymous 05.07.2017 / 09:20

0 answers