Skip to content

Instantly share code, notes, and snippets.

@shahoob
Last active September 17, 2020 13:31
Show Gist options
  • Save shahoob/7cbc47cececa5c4b42dd271e0fd33372 to your computer and use it in GitHub Desktop.
Save shahoob/7cbc47cececa5c4b42dd271e0fd33372 to your computer and use it in GitHub Desktop.
Basic Express.js v4 Hello, World Example
// 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