Created
September 3, 2021 14:22
-
-
Save zibellon/bee1c2289c03114d4cf579c8a994aecf to your computer and use it in GitHub Desktop.
Server first lesson
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 http = require('http'); | |
const cors = require('cors'); | |
const app = express(); | |
app.use(cors()); | |
app.use(express.urlencoded({ extended: true })); | |
app.use(express.json()); | |
app.use((req, res, next) => { | |
console.log('URL = ', req.url); | |
console.log('Original_URL = ', req.originalUrl); | |
console.log('METHOD = ', req.method); | |
console.log('HOST = ', req.headers.host); | |
console.log('IsSecure = ', req.secure); | |
console.log('BODY', req.body); | |
console.log('QUERY', req.query); | |
next(); | |
}); | |
app.all('/test', (req, res) => { | |
res.status(200).json({ message: 'KKKKKK'}); | |
}) | |
http.createServer(app).listen(3000, () => { | |
console.log('Server is working on port 3000'); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
жизнекрад через лес очень классно