Created
September 23, 2019 11:04
-
-
Save Musinux/aca546d0fca26d11141ec1a4564a20cc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* | |
* entrez la commande suivante: | |
* npm install --save express body-parser morgan cors | |
*/ | |
const express = require('express') | |
const bodyParser = require('body-parser') | |
const morgan = require('morgan') | |
const cors = require('cors') | |
const app = express() | |
app.use(morgan('dev')) | |
app.use(bodyParser.json()) | |
app.use(cors()) | |
app.get('/api/test', (req, res) => { | |
console.log('coucou') | |
res.json({ | |
message: "ceci est envoyé depuis l'API" | |
}) | |
}) | |
const port = process.env.PORT || 4000 | |
app.listen(port, () => { | |
console.log(`listening on ${port}`) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment