Last active
August 23, 2024 12:33
-
-
Save degrammer/37f13a470d46fb409a1efb0138f6f864 to your computer and use it in GitHub Desktop.
quick server
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 http = require('http'); | |
const url = require('url'); | |
const path = require('path'); | |
const fs = require('fs'); | |
const server = http.createServer((req, res) => { | |
const content = fs.readFileSync('index.html') | |
res.writeHead(200, {'Content-Type': 'text/html'}); | |
res.end(content); | |
}); | |
const PORT = 51772; | |
server.listen(PORT, () => { | |
console.log(`Server running at http://localhost:${PORT}/`); | |
}); |
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
{ | |
"name": "quick-server", | |
"version": "1.0.0", | |
"bin": "./index.js" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run this via
npx https://gist.github.com/degrammer/37f13a470d46fb409a1efb0138f6f864