-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
39 lines (29 loc) · 910 Bytes
/
server.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
var express = require('express');
var app = express();
var url = require('url');
var xml = require('xml');
var port = process.env.PORT || 8080;
app.use(function(req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type,Authorization');
next();
});
app.get('/', function(req, res) {
var query = url.parse(req.url, true).query;
console.log(query);
res.setHeader('Content-Type', 'application/xml');
res.send(xml({
response: [{
'playtext': 'Hello world!'
}]
}));
});
app.get('*', function(req, res) {
var query = url.parse(req.url, true).query;
console.log(query);
res.status(404).end();
});
var server = app.listen(port, function() {
console.log('Listening on ' + port);
});