Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express')
- const bodyParser = require('body-parser')
- const app = express()
- //app.use(express.static('www'))
- app.use(bodyParser.json())
- app.use(function (err, req, res, _next) {
- console.error(err.stack)
- res.status(500).send('Something is broken!')
- })
- //-----------------------------------------------------------------
- app.get('*', (req, res) => {
- console.log('GET', req.hostname, req.url, req.headers, req.body)
- res.send({})
- })
- app.post('*', (req, res) => {
- console.log('POST', req.hostname, req.url, req.headers, req.body)
- res.send({})
- })
- app.put('*', (req, res) => {
- console.log('POST', req.hostname, req.url, req.headers, req.body)
- res.send({})
- })
- app.delete('*', (req, res) => {
- console.log('POST', req.hostname, req.url, req.headers, req.body)
- res.send({})
- })
- /* Use PORT environment variable if it exists */
- const port = process.env.PORT || 8080
- server = app.listen(port, function () {
- console.log('Server listening on port %d in %s mode', port, app.settings.env)
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement