-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
57 lines (48 loc) · 1.19 KB
/
index.js
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
var express = require('express')
var bodyParser = require('body-parser')
var superagent = require('superagent')
var cheerio = require('cheerio')
var http = require('http')
var https = require('https')
var fs = require('fs')
var app = express()
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
app.use('/static', express.static('public'))
app.get('/', function(req, res) {
res.send('instagran-server')
})
app.post('/api/getimg', function(req, res) {
superagent
.post('http://www.dinsta.com/photos/')
.set('Content-Type', 'application/x-www-form-urlencoded')
.send({
url: req.body.url
})
.end(function(err, resp) {
if (err) {
throw err
}
var $ = cheerio.load(resp.text)
res.json({
url: $('img').attr('src')
})
})
})
app.get('/info', function(req, res) {
res.send(require('./ddb/db.json'))
})
app.use(function(err, req, res, next) {
console.error(err.stack)
res.status(500).send('500 Server Error')
})
http.createServer(app).listen(80)
https
.createServer(
{
pfx: fs.readFileSync('./www.littlee.xyz.pfx'),
passphrase: fs.readFileSync('./pass.pass')
},
app
)
.listen(443)