Created
March 3, 2020 19:15
-
-
Save jamesbiederbeck/1b9e18869f749ab5faab5759c54e9364 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env node | |
const express = require('express') | |
const app = express() | |
const port = 3000 | |
const response_text = 'Hello World!\nAlso more text here for testing\nAlso different text for lookbehind\n' | |
app.all("*", function (req, resp, next) { | |
console.log("Got request!"); | |
next(); | |
}); | |
app.get('/', (req, res) => res.send(response_text)) | |
app.get('/timeout/:time', function(req, res) { | |
timeout = req.param("time"); | |
console.log(`Per request, waiting ${timeout}`) | |
setTimeout(function(){ | |
console.log("No more lollygagging"); | |
res.send(response_text); | |
}, timeout) | |
; | |
}); | |
app.get('/empty/', function(req, res) { | |
console.log(`Per request, ending connection prematurely`); | |
res.end() | |
}); | |
app.listen(port, () => console.log(`Listening on port ${port}!`)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put this right before the last line:
app.get('*', function(req, res) {
res.send("This isn't the test you are looking for. You can go about your business, Move along.");
});