コード例 #1
0
ファイル: index.js プロジェクト: netbeast/netatmo
app.post('/config', function (req, res) {
  if (!(req.body.client_id.trim() && req.body.client_secret.trim() && req.body.username.trim() && req.body.password.trim())) {
    netbeast.error('Complete all fields!')
    res.sendFile(__dirname + dirsettings + '/index.html')
  } else {
    fs.writeJson('./src/settings/config.json', req.body, function (err) {
      if (err) console.trace(new Error(err))
    })
    app.use(require('./routes'))
  }
})
コード例 #2
0
ファイル: server.js プロジェクト: luisfpinto/music
app.post('/upload', upload.single('file'), function (req,res) {

	originalname = req.file.originalname
  
	if(req.file.mimetype !== 'audio/mp3' && req.file.mimetype !== 'audio/mp4' && req.file.mimetype != 'audio/mpeg') {
    netbeast.error('File Format not acceptable')    
    res.sendStatus(405)
  } 
  netbeast.find().then(function () {
       netbeast('music').set({track: 'http://' + process.env.NETBEAST + '/i/music/uploads/' + originalname, volume: 20})
    .then(function (data) {
           netbeast.info('Playing: ' + originalname)
           res.sendStatus(200)
    })
    .catch(function (error) {})
  })
})