-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudents.js
More file actions
33 lines (23 loc) · 1.02 KB
/
Copy pathstudents.js
File metadata and controls
33 lines (23 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import express from "express"
import cors from "cors"
const app = express()
const port = 4001
app.use(cors())
app.use(express.json())
let students = ["bob","samantha","lily","grace","jim"]
app.get("/movies/:movieTitle/:director", (req,res)=> { // for http://localhost:4000/movie/matrix ... If i'm searching in the mongoDB database
const movieTitle = req.params.movieTitle // get the actual movie title (everything to the right of "/movies/"
const director = req.params.director
console.log("director:",director)
console.log(`Looking for movie ${movieTitle}`) // Show me (to prove the obvios) what the user passed to me.
const query = {title: {'$regex': movieTitle, '$options': 'i'}};
let output = "<html><body> you asked for: " + movieTitle + "<BR>" // starts
for (let i = 0; i< students.length;i++) {
output = output + students[i] + "<br>" //middle
}
output = output + "</body></html>" //end
res.send(output)
})
app.listen(port,()=> {
console.log("localhost:" + port)
})