Answer the question
In order to leave comments, you need to log in
Browser Sync how to expand the functionality?
The task is as follows:
you need to stare the server and hang a post handler on the url '/post'
to emulate the delay in sending data, the ajax type and the protection of cross-domain requests
Answer the question
In order to leave comments, you need to log in
As the second parameter, the .init method takes a callback that returns a browsersync object that has an app property, this is connect server , and then themselves ...
browsersync.init
files:[
project + '**/*.html'
cssDir + '**/*.css'
jsDir + '**/*.js'
]
open: false
server:
baseDir: project
,(err,bs)->
if err
gutil.log err
return do gutil.beep
bs.app.use '/post', (req, res, next) ->
setTimeout (->
res.end 'Speed: 1'
return
), 1000
bs.app.use '/post3', (req, res, next) ->
setTimeout (->
res.end 'Speed: 3'
return
), 3000
opn "http://localhost:3000"
return browsersync.init({
files: [project + '**/*.html', cssDir + '**/*.css', jsDir + '**/*.js'],
open: false,
server: {
baseDir: project
}
}, function(err, bs) {
if (err) {
gutil.log(err);
return gutil.beep();
}
bs.app.use('/post', function(req, res, next) {
return setTimeout((function() {
res.end('Speed: 1');
}), 1000);
});
bs.app.use('/post3', function(req, res, next) {
return setTimeout((function() {
res.end('Speed: 3');
}), 3000);
});
return opn("http://localhost:3000");
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question