8
8
* */
9
9
var express = require ( 'express' ) ,
10
10
http = require ( 'http' ) ,
11
- //upload = require('../index');
12
- upload = require ( 'jquery-file-upload-middleware' ) ; // don't work 0.0.8 && update > 0.0.8
11
+ upload = require ( '../' ) ;
13
12
14
- var cons = require ( 'consolidate' ) ,
15
- swig = require ( 'swig' ) ;
13
+ var swig = require ( 'swig' ) ;
16
14
17
15
18
16
// configuration
@@ -26,15 +24,12 @@ var app = express();
26
24
27
25
28
26
// set template engine
29
- app . engine ( 'html' , cons . swig ) ;
30
- swig . init ( {
31
- root : __dirname + '/views' ,
32
- allowErrors : true ,
33
- cache : false
27
+ app . engine ( 'html' , swig . renderFile ) ;
28
+ swig . setDefaults ( {
29
+ cache : false // default 'memory'
34
30
} ) ;
35
31
36
32
37
-
38
33
// jquery-file-upload helper
39
34
app . use ( '/upload/default' , function ( req , res , next ) {
40
35
upload . fileHandler ( {
@@ -74,6 +69,7 @@ upload.on('end', function (fileInfo) {
74
69
75
70
upload . on ( 'delete' , function ( fileName ) {
76
71
// remove file info
72
+ console . log ( "files remove complete" ) ;
77
73
console . log ( fileName ) ;
78
74
} ) ;
79
75
@@ -114,7 +110,11 @@ app.configure('production', function () {
114
110
* routes
115
111
* */
116
112
app . get ( '/' , function ( req , res ) {
117
- res . send ( 'Call this url in browser : http://localhost:3001/location/input' ) ;
113
+ var html = [
114
+ '<p>Call this url in browser : http://localhost:3001/location/input <a href="/location/input">Go</a></p>' ,
115
+ '<p>Call this url in browser : http://localhost:3001/upload/location/list <a href="/upload/location/list">Go</a></p>'
116
+ ] . join ( '' ) ;
117
+ res . send ( html ) ;
118
118
} ) ;
119
119
120
120
@@ -140,4 +140,5 @@ app.post('/location/input', function (req, res) {
140
140
http . createServer ( app ) . listen ( app . get ( 'port' ) , function ( ) {
141
141
console . log ( "Express server listening on port " + app . get ( 'port' ) ) ;
142
142
console . log ( "access url /location/input" ) ;
143
+ console . log ( "access url /upload/location/list" ) ;
143
144
} ) ;
0 commit comments