18 lines
460 B
JavaScript
18 lines
460 B
JavaScript
const express = require("express")
|
|
const app = express()
|
|
const PORT = 3000
|
|
|
|
app.get("/user/:id", function(req, res) { // po dwukropku informacje są traktowane jako parametr pomimo że "są ścieżką"
|
|
let id = req.params.id
|
|
if(id == 2) {
|
|
res.send("Odsyłam stronę usera z id = 2")
|
|
} else {
|
|
res.send(`Jakieś dziwne to id... ${id}?!`)
|
|
}
|
|
|
|
})
|
|
|
|
app.listen(PORT, function() {
|
|
console.log("Serwer uruchomiony, port " + PORT)
|
|
})
|