Created
February 29, 2020 17:59
-
-
Save munkacsitomi/feeabe8f652753b674a7c6072e7f5a8e to your computer and use it in GitHub Desktop.
A Node.js application using Express.js
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
const port = 3000; | |
const express = require('express'); | |
const app = express(); | |
const getJSONString = (obj) => JSON.stringify(obj, null, 2); | |
app | |
.get('/', (req, res) => { | |
console.log(`Method: ${getJSONString(req.method)}`); | |
console.log(`URL: ${getJSONString(req.url)}`); | |
console.log(`Headers: ${getJSONString(req.headers)}`); | |
res.send('Hello, Express.js!'); | |
}) | |
.listen(port, () => { | |
console.log(`The Express.js server has started and is listening on port number: ${port}`); | |
}); |
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
{ | |
"name": "express-project", | |
"version": "1.0.0", | |
"description": "A Node.js application using Express.js", | |
"main": "main.js", | |
"scripts": { | |
"start": "node main.js" | |
}, | |
"author": "Tamas Munkacsi", | |
"license": "ISC", | |
"dependencies": { | |
"express": "^4.17.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment