Shaheen
Shaheen

Reputation: 1

Cloud9 io nodejs with ejs throwing error "Cannot GET /"

I'm getting the error "Cannot GET /" on preview, I'm providing the app.js file for reference

var express = require("express");
var app = express();
var request= require("request");
app.set("view engine" ,"ejs");
app.listen(process.env.PORT,process.env.IP,function(){
    console.log("server has started");
});
app.get("/results", function(req,res){
    console.log(req.query.search);
    var url="http://www.omdbapi.com/?apikey=thewdb&s=" + "iowa";
    request(url, function(error,respone,body){
        if(! error && respone.status.Code == 200){
            var data = JSON.parse(body);
            res.render("results", {data:data});
        }
    });
});

Upvotes: 0

Views: 158

Answers (1)

Ishwar Patil
Ishwar Patil

Reputation: 1736

You have not specified / route.

app.get('/', function(....));

should be added.

Upvotes: 1

Related Questions