server.listen(SERVER_DEPORT, function () { this.console.info('webpack1 server is running at :' + SERVER_DEPORT + ' ,please visit: http://localhost:' + SERVER_DEPORT); this.utils.open('http://localhost:' + SERVER_DEPORT); }.bind(this));
gulp.task('webserver', function() { var app = connect(); app.use(serveStatic('./')); app.listen(8000); });
app//.use(query()) .use(function (req, res, next) { res.setHeader('Content-Type', 'application/json') res.end(JSON.stringify(req.query)) }) .listen(3001)
app.listen(3000, function () { var host = server.address().address; var port = server.address().port; console.log('custom server listening at http://%s:%s', host, port); })
connect() .use(bodyParser.urlencoded({ extended: false, limit: 10, verify: verifyRequest })) .use((req, res, next) => { res.setHeader('Content-Type', 'text/plain'); res.end('You sent: ' + JSON.stringify(req.body) + '\n'); }) .listen(3000);
app .use(logger('dev')) .use((req, res, next) => { setTimeout(() => { next(new Error('something broke !')) }, 500) }) .use(errorHandler()) .listen(3001)
connect() .use((req, res, next) => { console.log(req._parsedUrl.query); req.query = qs.parse(req._parsedUrl.query); next(); }) .use((req, res) => { console.log('query string:', req.query); res.end('\n'); }) .listen(3000);
app.use(serveIndex(path, {"icons": true})).listen(port, function() { if (!argv.silent) { openUrl('http://' + hostname + ':' + port); } console.log('server is running at http://%s:%s', hostname, port); });
connect() .use(cookieParser()) .use((req, res, next) => { res.end(JSON.stringify(req.cookies)); }) .listen(3000);
app.use(favicon(__dirname, '/public/favicon.ico')) .use(logger()) .use(function (req, res) { res.end('hello world! \n') }) .listen(3000)
connect() .use(multipart()) .use((req, res, next) => { console.log(req.files); res.end('Upload received\n'); }) .listen(3000);
connect() .use(bodyParser.json()) .use((req, res, next) => { res.setHeader('Content-Type', 'application/json'); res.end('Name: ' + req.body.name + '\n'); }) .listen(3000);
connect() .use(morgan('combined')) .use((req, res) => { res.setHeader('Content-Type', 'application/json'); res.end('Logging\n'); }) .listen(3000);
server.listen(SERVER_DEPORT, function () { this.console.info('webpack1 server is running at :' + SERVER_DEPORT + ' ,please visit: http://localhost:' + SERVER_DEPORT); this.utils.open('http://localhost:' + SERVER_DEPORT); }.bind(this));
connect() .use(bodyParser.urlencoded({ extended: false })) .use((req, res, next) => { res.setHeader('Content-Type', 'text/plain'); res.end('You sent: ' + JSON.stringify(req.body) + '\n'); }) .listen(3000);