Created
July 10, 2021 19:19
-
-
Save johnny12150/85c4b44d0361fa508265864f6c4b34c6 to your computer and use it in GitHub Desktop.
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
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}`) | |
}) |
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
{ | |
"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" | |
} | |
} |
Author
johnny12150
commented
Jul 11, 2021
- https://expressjs.com/zh-tw/guide/routing.html
- https://expressjs.com/zh-tw/starter/hello-world.html
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment