-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
50 lines (40 loc) · 1.14 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
var express = require('express'),
app = express(),
bodyParser = require('body-parser'),
multer = require('multer'),
dotenv = require('dotenv').config()
/*
* using multer for file upload
* when the user is getting a file from his computer
*/
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, './public/uploads')
},
filename: function (req, file, cb) {
cb(null, Date.now() + '-' + file.originalname)
}
})
var upload = multer({ storage: storage })
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
extended: true
}))
app.use(express.static(__dirname + '/public'))
/*
* routes declaration
*/
var visual_reco_route = require('./routes/visual-reco'),
text_to_speech_route = require('./routes/text-to-speech')
app.get('/', function(req, res) {
res.sendFile('index.html', {
root: 'public'
})
})
app.post('/classifyurl', visual_reco_route.classifyFromURL)
app.post('/classifyfile', upload.single('images_file'), visual_reco_route.classifyFromFile)
app.post('/tospeech', text_to_speech_route.toSpeech)
var port = 3000
app.listen(port, function() {
console.log('listening at:', port)
})