Created
July 10, 2020 06:37
-
-
Save yushulx/e6cf69afa9e4ab1cfdfdeb00d2d27a2a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const http = require('http'); | |
var server = http.createServer(function (req, res) { | |
if (req.url === '/' || req.url === '/index.htm') { | |
res.writeHead(200, { 'Content-Type': 'text/html' }); | |
res.write(html); | |
res.end(); | |
} | |
else if (req.url.startsWith("/image")) { | |
res.writeHead(200, { 'Content-Type': 'image/jpeg' }); | |
res.write(img); | |
res.end(); | |
} | |
else | |
res.end('Invalid Request!'); | |
}); | |
server.listen(2020); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment