Created
November 26, 2018 18:11
-
-
Save par38/4f0c9a965fa3a416699dc94736a774e7 to your computer and use it in GitHub Desktop.
Serveur HTTP (NodeJS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html | |
head | |
title= title | |
body | |
h1= message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
//const connection = require('./conf'); // appelle conf.js | |
app.set('views', './views'); | |
app.set('view engine', 'pug'); | |
app.get('/', function (req, res) { | |
res.render('index', { title: 'Accueil', message: `Bienvenue sur la page d'accueil!`}); | |
}); | |
app.get('/about', function (req, res) { | |
res.render('index', { title: 'Propos', message: 'A propos...'}); | |
}); | |
app.listen(port, (err) => { | |
if (err) | |
return console.log('something bad happened', err) | |
console.log(`server is listening on ${port}`) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment