Created
April 30, 2020 02:35
-
-
Save sandrabosk/0a5461c5189913e7e2babd85d03b5c19 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
// 1: npm i dotenv | |
// 2: require packages | |
const http = require('http'); | |
require('dotenv').config(); | |
const PORT = process.env.PORT || 3000; // You can set default port to 3000 if port is not defined | |
// 3: create server (and use packages): | |
const myServer = http.createServer((request, response) => { | |
console.log(`Success, I'm listening from the port: ${PORT}`); | |
response.end(); | |
}); | |
// 4: server listens on the port 3000 | |
myServer.listen(process.env.PORT, () => console.log('I am 🏃♂️ on port 3000!')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment