forked from purescript-contrib/purescript-affjax
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-server.js
More file actions
39 lines (29 loc) · 883 Bytes
/
test-server.js
File metadata and controls
39 lines (29 loc) · 883 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
36
37
38
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
// Always make req.body available as a String
app.use(bodyParser.text(function() { return true; }));
app.use(express.static(__dirname));
app.get('/', function (req, res) {
res.send('<html><script src="tmp/test.js"></script></html>');
});
app.get('/arrayview', function(req, res) {
res.send('TODO');
});
app.get('/not-json', function(req, res) {
res.header({'content-type': 'text/plain'});
res.send('This is not JSON');
});
app.all('/mirror', function(req, res) {
res.json({
headers: req.headers,
body: req.body,
query: req.query,
method: req.method,
});
});
var server = app.listen(3838, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Test server listening at http://%s:%s', host, port);
});