# Your First Server — Express.js

Source: https://www.geekswithgeeks.com/en/expressjs/ex-hello-world

> A running Express server in under ten lines.

## Hello, World!

Create an app, define one route, start listening. Save as `server.js` and run with `node server.js`.

```javascript
import express from 'express';

const app = express();

app.get('/', (req, res) => {
  res.send('Hello, World!');
});

app.listen(3000, () => {
  console.log('Server running on http://localhost:3000');
});
```

Output:

```
Server running on http://localhost:3000
```

## app, listen, and the request handler

`express()` creates the app instance. `app.get(path, handler)` registers a route. `app.listen(port)` starts the HTTP server and keeps the process alive.

**Quiz:** What does `app.listen(3000)` do?

- [x] Starts the server and binds it to port 3000
- [ ] Registers a new route
- [ ] Parses incoming JSON

*Answer:* Starts the server and binds it to port 3000. `listen` binds and starts the underlying HTTP server on the given port.
