What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-11-11 18:13:17
multer
// Installation // npm install --save multer // Usage var express = require('express') var multer = require('multer') var upload = multer({ dest: 'uploads/' }) var app = express() app.post('/profile', upload.single('avatar'), function (req, res, nex... Add solution -
Javascript 2021-11-10 19:16:11
body-parser node
//make sure it is in this order npm i body-parser const express = require('express') const bodyParser = require('body-parser') const app = express() // parse application/x-www-form-urlencoded app.use(bodyParser.urlencoded({ extended: false })) // pars... Add solution -
Javascript 2021-11-09 17:24:12
Express.js - app.listen vs server.listen
//The second form (creating an HTTP server yourself, instead of having Express create one for you) is useful if you want to reuse the HTTP server, for example to run socket.io within the same HTTP server instance: var express = require('express'); var ap... Add solution -
Javascript 2021-11-09 17:09:08
express signed cookies
var express = require('express'); var cookieParser = require('cookie-parser'); var app = express(); app.use(cookieParser('YOUR-SECRET-SALT')); app.get('/', (req, res, next) => { res.cookie('name', 'value', { signed: true }); res.send('Success'); ... Add solution -
Javascript 2021-11-09 06:03:13
sample express app
//to run : node filename.js 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}`)) /... Add solution -
Javascript 2021-11-09 05:33:19
node express server static files
var express = require('express'); var app = express(); var path = require('path'); //app.use(express.static(__dirname)); // Current directory is root app.use(express.static(path.join(__dirname, 'public'))); // "public" off of current is root ... Add solution -
Html 2021-11-08 16:49:18
express serve html
const path = require('path') const express = require('express') const app = express() const port = process.env.PORT || 3000 const publicDirectoryPath = path.join(__dirname, '../public') app.use(express.static(publicDirectoryPath)) app.listen(port, () ... Add solution -
Javascript 2021-11-08 11:02:28
How to Create a Secure REST API with Node.js and Express
/* This code comes from Vincent Lab And it has a video version linked here: https://www.youtube.com/watch?v=Tw5LupcpKS4 */ // Import dependencie const express = require("express"); // Setup the express server const app = express(); con... Add solution
Best helpers
Bob R Bogle
+5
Eric Vought
+5
James Song
+5
Fishbean
+5
Mai Rose
+5
Cpurick
+5
Puneet Goel
+5
Bunch
+5
Rainbow
+5
Gruppetto
+5
Katboodle
+5
Vidhi Patel
+5
Buttercup
+5
Bin Nguyễn
+5