-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (22 loc) · 724 Bytes
/
app.js
File metadata and controls
28 lines (22 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var express = require('express');
var app = express();
var request = require("request");
app.set("view engine","ejs");
app.get('/',function(req,res){
res.render('search')
});
app.get("/result",(req,res) => {
var query = req.query.search;
var url = 'http://www.omdbapi.com/?s=' + query +'&plot=full&apikey=thewdb';
request(url,(error,response,body) => {
if(!error && response.statusCode==200){
//var results = JSON.parse(body)
var data = JSON.parse(body)
res.render("result",{data: data});
// res.send(results["Search"][0]["Title"]);
}
});
});
app.listen(3000,function(){
console.log("movie has started");
});