-
-
Save Romanmir/9894323d8044a2aebe1d0964c14ea3f4 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