Last active
September 17, 2020 13:31
-
-
Save shahoob/7cbc47cececa5c4b42dd271e0fd33372 to your computer and use it in GitHub Desktop.
Basic Express.js v4 Hello, World Example
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
// This code is also express@5 compatible! | |
const express = require('express'); | |
const app = express(); | |
const port = 3000; // You can change the port by replacing '3000' with any number. But not like this: 'your port here' | |
app.get('/', (req, res) => res.send('Hello, World!')); | |
app.listen(port, () => console.log(`Server started on ${port} | |
To connect to your server, go to http://localhost:${port} | |
`)); | |
/* | |
Prints: | |
Server started on 3000 | |
To connect to your server, go to http://localhost:3000 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment