xxxxxxxxxx
Express.js, or simply Express, is a web application framework for Node.js,
released as free and open-source software under the MIT License.
It is designed for building web applications and APIs.
It has been called the de facto standard server framework for Node.js.
You can use express for high based sites.
xxxxxxxxxx
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
xxxxxxxxxx
const express = require('express');
const app = express();
const port = 3000;
const rotas = require('./rotas');
app.use(express.json());
app.use(rotas); // app.get('/', (req, res) => {
// res.send('Hello World!')
//})
app.listen(port, () => console.log(`Servidor rodando na porta ${port}!`))
xxxxxxxxxx
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
xxxxxxxxxx
1)Express is minimal node.js framework,higher level of abstraction.
2)Express contains robust set of features:complex routing,easier handling of request
and responses,middleware,server-side rendering etc.
3)express allows application into the MVC architecture.
//index.js
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.json({ msg: 'Hello from server' });
});
app.listen(4000, () => {
console.log('Hello from server');
});
xxxxxxxxxx
const express = require('express')
const App = express()
const Port = 3000
App.get('/', (req, res) => {
res.send('Hello World!')
})
App.listen(Port, () => {
console.log(`Express app listening at ${Port}`)
})
xxxxxxxxxx
const express = require('express');
const app = express();
const port = 3000;
app.get('/', (req, res) => {
res.send('Hello World!')
});
app.listen(port, () => {
console.log(`App listening at http://localhost:${port}`)
});
xxxxxxxxxx
Express is a minimal and flexible Node.js web application framework
that provides a robust set of features for web and mobile
applications.
xxxxxxxxxx
const path = require('path');
const methodOverride = require('method-override');
engine = require('ejs-mate');
app.engine('ejs', engine);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(express.static(path.join(__dirname, 'public')))
app.use(methodOverride("_method"));
app.use(express.urlencoded({ extended: true }))
app.use(express.json());