Skip to content

Instantly share code, notes, and snippets.

@johnny12150
Created July 10, 2021 19:19
Show Gist options
  • Save johnny12150/85c4b44d0361fa508265864f6c4b34c6 to your computer and use it in GitHub Desktop.
Save johnny12150/85c4b44d0361fa508265864f6c4b34c6 to your computer and use it in GitHub Desktop.
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
// POST method route
app.post('/', function (req, res) {
res.send('POST request to the homepage');
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
{
"name": "first-api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"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