Last active
January 29, 2019 14:45
-
-
Save Roiseuxquentin/d60278a8bcf6e459f041c02211e802f6 to your computer and use it in GitHub Desktop.
Basic Express Server
This file contains 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
const express = require('express') | |
const bodyParser = require('body-parser') | |
const cors = require('cors') | |
const app = express() | |
// Middleware | |
app.use(bodyParser.urlencoded({ extended: true })) | |
app.use(cors()) | |
app.get('/', (req, res) => { | |
console.log("Ping") | |
res.send('Pong' ) | |
}) | |
app.post('/post', (req, res) => { | |
const DATA = req.body.data | |
res.send(`${DATA} DAFTPUNK HUGO BANKSY`) | |
console.log('Data recus :', DATA) | |
}) | |
app.get('/dataurl/:data', (req, res) => { | |
const DATA = req.params.data | |
res.send(`Sp4Wn JOK3R Ven0m`) | |
console.log('Data recus :', DATA) | |
}) | |
app.listen(8080, () => console.log('serveur sur le port 8080')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment