-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
59 lines (38 loc) · 1.24 KB
/
Copy pathindex.js
File metadata and controls
59 lines (38 loc) · 1.24 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const express=require('express') ;
const engine=require('ejs-locals') ;
const path=require('path') ;
const Request=require('request');
const http=require('http');
const app=express() ;
const bodyParser=require('body-parser');
const urlencodedParser = bodyParser.urlencoded({ extended: false })
app.engine('ejs',engine) ;
app.set('view engine','ejs');
app.set('views', path.join(__dirname, 'views'));
const server=http.Server(app);
app.get('/',(req,res)=>{
res.render('home');
// Request.get('https://saksham-github-api.herokuapp.com',(err,ress,body)=>{
// console.log((body));
// });
});
app.post('/find',urlencodedParser,(reqq,ress)=>{
dt=reqq.body;
aa=dt['t1'];
Request.post({
'headers':{'content-type':'application/json'},
'url':'https://saksham-github-api.herokuapp.com/get_repo',
'body':JSON.stringify({
'repo':aa
})
},(err,res,body)=>{
// console.log(JSON.parse(body));
var bc=JSON.parse(body);
ress.render('result',{'data':bc,'dta':aa});
});
// ress.render('result',{'data':data});
});
app.listen(process.env.PORT || 7500,'0.0.0.0',()=>{
//console.log(app.get('views'))
console.log(`Express running→PORT 7500`);
});