Skip to content

Instantly share code, notes, and snippets.

@degrammer
Last active January 19, 2024 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save degrammer/37f13a470d46fb409a1efb0138f6f864 to your computer and use it in GitHub Desktop.
Save degrammer/37f13a470d46fb409a1efb0138f6f864 to your computer and use it in GitHub Desktop.
quick server
#!/usr/bin/env node
const http = require('http');
const url = require('url');
const server = http.createServer((req, res) => {
const parsedUrl = url.parse(req.url, true);
const queryStringParams = parsedUrl.query;
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(`The code parameter is: ${queryStringParams.code || 'Not provided'}\n`);
});
const PORT = 51772;
server.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}/`);
});
{
"name": "quick-server",
"version": "1.0.0",
"bin": "./index.js"
}
@degrammer
Copy link
Author

Run this via npx https://gist.github.com/degrammer/37f13a470d46fb409a1efb0138f6f864

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment