26 lines
579 B
JavaScript
26 lines
579 B
JavaScript
const express = require("express")
|
|
const app = express()
|
|
const PORT = 3000
|
|
|
|
app.get("/", function(req, res) {
|
|
html = '<html><head><title>Linki</title></head><body>'
|
|
|
|
for(let i = 0; i < 100; i++) {
|
|
let random = Math.floor(Math.random() * 100)
|
|
html += `<a href="/product/${random}">Produkt ${random}</a><br>`
|
|
}
|
|
|
|
html += '</body></html>'
|
|
res.send(html)
|
|
})
|
|
|
|
app.get("/product/:id", function(req, res) {
|
|
let id = req.params.id
|
|
|
|
res.send("podstrona z danymi produktu o id = " + id)
|
|
})
|
|
|
|
app.listen(PORT, function() {
|
|
console.log(PORT)
|
|
})
|