Commit d73ede6e authored by james's avatar james

[ADD] api init

parent bff7624c
Pipeline #2842 failed with stages
# nodejs_tutorial # nodejs_tutorial
Nodejs教學分享
\ No newline at end of file npm i
npm start
\ No newline at end of file
console.log('Hello World'); const express = require('express')
\ No newline at end of file const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World! (get')
})
app.post('/', (req, res) => {
res.send('Hello World! (post')
})
app.put('/', (req, res) => {
res.send('Hello World! (put')
})
app.delete('/', (req, res) => {
res.send('Hello World! (delete')
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
\ No newline at end of file
This diff is collapsed.
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"description": "Nodejs教學分享", "description": "Nodejs教學分享",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "start": "node index.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
...@@ -12,5 +12,8 @@ ...@@ -12,5 +12,8 @@
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "ISC" "license": "ISC",
"dependencies": {
"express": "^4.18.1"
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment