From 2941fb01eab4bd47b80f1b17958472fa3da6163d Mon Sep 17 00:00:00 2001 From: DridriLaBastos <19534959+DridriLaBastos@users.noreply.github.com> Date: Sun, 22 Nov 2020 14:14:07 +0100 Subject: [PATCH] Ajout d'un serveur HTTP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deux serveurs HTTP et HTTPS sont démarrés avec node. Cela permet d'afficher l'emploi du temps lorsque l'on se connecte au serveur http dans firefox (la version https ne fonctionne pas encore donc pas encore d'affichage dans safari --- index.js | 14 +++++++++++++- package.json | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 6c57fce..ade69f4 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,10 @@ const compression = require( 'compression' ); const express = require( 'express' ); const app = express(); const port = 3000; +const httpPort = 800; +const httpsPort = 4430; +const http = require('http'); +const https = require('https'); // EJS app.set( 'views', './views' ); @@ -87,4 +91,12 @@ app.use( ( req, res, next ) => { app.listen( port, () => { console.log( `Server listening at http://localhost:${port}` ); -} ); \ No newline at end of file +} ); + +http.createServer(app).listen(httpPort, () => { + console.log( `HTTP server listening at http://localhost:${httpPort}` ); +}); + +https.createServer(app).listen(httpsPort, () => { + console.log( `HTTPS server listening at http://localhost:${httpsPort}` ); +}) \ No newline at end of file diff --git a/package.json b/package.json index 41f3446..720b15e 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "Info Evry Website", "main": "index.js", "scripts": { - "start": "nodemon --ext \"js,ejs,css\" ." + "start": "node .", + "dev": "nodemon --ext \"js,ejs,css\" ." }, "repository": { "type": "git",