Skip to content
Snippets Groups Projects
Commit bfcb9b10 authored by VILLAUME Lucas's avatar VILLAUME Lucas
Browse files

Base du serveur

parent 35fbc3dd
Branches
Tags
No related merge requests found
app.js 0 → 100644
const express = require('express');
const app = express();
module.exports = app;
app.get("/", defaut);
app.all("*", (req, res) => res.status(404).send("<h1>Il semblerait que cette page n'existe pas.</h1>"))
function defaut(req, res){
let body = `<h1>Accueil</h1><br><p>${req.method} pour l'adresse ${req.url}</p>`;
res.status(200);
res.type("html");
res.send(body);
}
\ No newline at end of file
This diff is collapsed.
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "node index.js", "start": "node index.js",
"serv_start": "node server.js",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"repository": { "repository": {
...@@ -14,6 +15,6 @@ ...@@ -14,6 +15,6 @@
"author": "Mohamad ALTAWEEL, Elhadji Moussa FAYE, Ludovic Tagnon, Lucas Villaume", "author": "Mohamad ALTAWEEL, Elhadji Moussa FAYE, Ludovic Tagnon, Lucas Villaume",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"Express": "^3.0.1" "express": "^4.18.2"
} }
} }
const http = require('http');
const app = require('./app.js');
const serv = http.createServer(app);
serv.listen(3500, () => console.log("Serveur lancé !"));
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment