Created
March 20, 2022 14:40
-
-
Save sallos-cyber/1c6ff5c559701a75bdacfecbc7ea3495 to your computer and use it in GitHub Desktop.
to use node.js as http 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
const express = require('express') | |
const path = require('path') | |
const httpPort = 1026 | |
const app = express() | |
app.use(express.static(path.join(__dirname, './'))) | |
app.get('/', function(req, res) { | |
res.sendFile(path.join(__dirname, './index.html')) | |
}) | |
app.listen(httpPort, function () { | |
console.log(`Listening on port ${httpPort}!`) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment