aboutsummaryrefslogtreecommitdiff
path: root/practice/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'practice/index.js')
-rw-r--r--practice/index.js30
1 files changed, 26 insertions, 4 deletions
diff --git a/practice/index.js b/practice/index.js
index c916bed..f121c37 100644
--- a/practice/index.js
+++ b/practice/index.js
@@ -1,8 +1,30 @@
-const http = require('http')
+const express = require('express')
+const app = express()
-const app = http.createServer((request, response) => {
- response.writeHead(200, { 'Content-Type': 'text/plain' })
- response.end('Habari Tanzania')
+let notes = [
+ {
+ id: 1,
+ content: "HTML is easy",
+ important: true
+ },
+ {
+ id: 2,
+ content: "Browser can execute only JavaScript",
+ important: false
+ },
+ {
+ id: 3,
+ content: "GET and POST are the most important methods of HTTP protocol",
+ important: true
+ }
+]
+
+app.get('/', (request, response) => {
+ response.send('<h1>Habari Tanzania</h1>')
+})
+
+app.get('/api/notes', (request, response) => {
+ response.json(notes)
})
const PORT = 3001