forked from charted-co/charted
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (27 loc) · 780 Bytes
/
index.js
File metadata and controls
35 lines (27 loc) · 780 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
29
30
31
32
33
34
35
/*jshint node:true */
var request = require('request')
var express = require('express')
var app = express()
app.get('/get', function (req, res) {
if (!req.query.url) {
res.status(400).send('Bad Request: no url provided')
return
}
request(decodeURIComponent(req.query.url), function (err, resp, body) {
if (err) {
res.status(400).send('Bad Request: ' + err)
return
}
if (resp.statusCode != 200) {
res.status(400).send('Bad Request: response status code was not 200')
return
}
res.status(200).send(body)
})
})
app.use(express.static('pub'))
var server = app.listen(3000, function () {
var host = server.address().address
var port = server.address().port
console.log('Running at http://%s:%s', host, port)
})