к node js?
// app.js
const express = require('express')
const bodyParser = require("body-parser");
const config = require('config')
const homeRouter = require('./routes/homeRouter')
const app = express()
app.use('/', homeRouter)
const PORT = config.get('port') || 5000
app.listen(PORT, () => console.log(`App has been started on port ${PORT} `))
//homeControllers.js
exports.index = (req, res) => {
res.render('index', function (err, html) {
res.send(html)
})
//homeRouter.js
const express = require('express')
const homeController = require('../controllers/homeControllers')
const homeRouter = express.Router()
homeRouter.get("/about", homeController.about);
homeRouter.get("/", homeController.index);
module.exports = homeRouter;
Стикер
res.sendFile(__dirname + "/views/index.html");
Обсуждают сегодня