Skip to content

Instantly share code, notes, and snippets.

@par38
Created November 26, 2018 18:11
Show Gist options
  • Save par38/4f0c9a965fa3a416699dc94736a774e7 to your computer and use it in GitHub Desktop.
Save par38/4f0c9a965fa3a416699dc94736a774e7 to your computer and use it in GitHub Desktop.
Serveur HTTP (NodeJS)
html
head
title= title
body
h1= message
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