Friday 5 May 2017

express-flash-notification shows error "No default engine was specified and no extension was provided"

I am new in node.js I am using MEAN for my project.In my project I have an option to "Subscribe email" at footer. Because of footer I can't use Angular for flash message (I dont have any controller). Using normal node.js I need to display the flash message.

Here is my code server.js

var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var session = require('express-session');
var flash           = require('express-flash-notification')
var cookieParser    = require('cookie-parser')



app.use(cookieParser("hash"));   
app.use(session({secret:"hash", cookie: { maxAge: 60000 }, resave: true, saveUninitialized: true }))

app.use(bodyParser.urlencoded({extended:true}));
app.use(bodyParser.json());
app.use(express.static('public'));

app.use(flash(app));
app.use(express.static(__dirname + '/client'));
app.use('/admin', express.static(__dirname + '/admin'));

app.use('/', express.static(__dirname + '/client', { redirect: false }));



app.post('/subscribe', function (req, res)
 {
    if(req.body.name == 'aathirag@gmail.com') 
    {
        //return console.log(error);
        //res.send(200);
        req.flash('info', 'Thank you', 'home')

    }
    else
    {
        res.send(500);
    }





});




app.listen(3000, function(){
    console.log('server is running on port 3000..');
});

and html file

<!DOCTYPE html>
<html lang="en">

<body>
    <!-- footer -->
<div>
<form action="/subscribe" method="POST">

    <input name="name" id="name" type="text"  placeholder="Enter your email address" /><input type="submit" name="submit" id="submit" class="newsletter-submit" />


</form>
</div>

</body>
</html>

this shows error "No default engine was specified and no extension was provided".

How to fix this and how I can show message in html page. I have tried

 

but its not working

Thank you



via Athi

No comments:

Post a Comment