Angular/Production-texte-unique : Différence entre versions

De WikiSys
Aller à : navigation, rechercher
(initialiase)
Ligne 1 : Ligne 1 :
== initialiase ==
+
== initialisation ==
  
 
  cd ~Angular
 
  cd ~Angular
Ligne 32 : Ligne 32 :
  
 
If you try and make a request to your server, you should get back a JSON object containing the message we have specified.
 
If you try and make a request to your server, you should get back a JSON object containing the message we have specified.
 +
 +
 +
git commit -m "backend/server.js backend/app.js localhost:3000 JSON message"
 +
== ==

Version du 14 juillet 2019 à 16:09

initialisation

cd ~Angular
ng new production-texte-unique --style=scss --skip-tests=true
routing y
cd production-texte-unique/
mkdir backend
backend/emacs app.js
const express = require('express');

const app = express();

app.use((req, res) => {
  res.json({ message: 'Your request was successful!' }); 
});

module.exports = app;

backend/server.js
const http = require('http');
const app = require('./app');

const port = process.env.PORT || 3000;
app.set('port', port);

const server = http.createServer(app);

server.listen(process.env.PORT || 3000);
console.log('Listening on port http://localhost:' + port);

If you try and make a request to your server, you should get back a JSON object containing the message we have specified.


git commit -m "backend/server.js backend/app.js localhost:3000 JSON message"