-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
35 lines (27 loc) · 971 Bytes
/
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
var express = require('express');
var logger = require('morgan');
var path = require('path');
var config = require('./config');
var routing = require('./img').routing;
var app = module.exports = express();
app.use(logger('dev'));
app.use('/upload', express.static(path.join(__dirname, '/upload')));
app.use(function(err, req, res, next){
res.send(err);
})
app.route('/')
.get(function(req, res, next){
res.send('<form method="post" enctype="multipart/form-data">'
+ '<p>Title: <input type="text" name="title" /></p>'
+ '<p>Image: <input type="file" name="image" /></p>'
+ '<p><input type="submit" value="Upload" /></p>'
+ '</form>');
})
.post(routing.upload);
app.get('/img/:url', routing.getImg);
app.get('/all', routing.allImg);
app.get('*', function(req, res, next){
next("Not found");
});
app.listen(config.get("port"));
console.log('Express started on port ' + config.get("port"));