| 
									
										
										
										
											2017-09-05 05:26:50 +00:00
										 |  |  | #!/usr/bin/env node
 | 
					
						
							|  |  |  | /* xlsx.js (C) 2013-present  SheetJS -- http://sheetjs.com */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var fs = require('fs'), path = require('path'); | 
					
						
							|  |  |  | var express = require('express'), app = express(); | 
					
						
							|  |  |  | var sprintf = require('printj').sprintf; | 
					
						
							| 
									
										
										
										
											2017-09-12 20:02:06 +00:00
										 |  |  | var logit = require('../server/_logit'); | 
					
						
							|  |  |  | var cors = require('../server/_cors'); | 
					
						
							| 
									
										
										
										
											2017-09-05 05:26:50 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | var port = +process.argv[2] || +process.env.PORT || 7262; | 
					
						
							|  |  |  | var basepath = process.cwd(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-13 02:51:54 +00:00
										 |  |  | var dir = path.join(__dirname, "files"); | 
					
						
							|  |  |  | try { fs.mkdirSync(dir); } catch(e) {} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-12 20:02:06 +00:00
										 |  |  | app.use(logit.mw); | 
					
						
							|  |  |  | app.use(cors.mw); | 
					
						
							| 
									
										
										
										
											2018-03-13 02:51:54 +00:00
										 |  |  | app.use(require('express-formidable')({uploadDir: dir})); | 
					
						
							| 
									
										
										
										
											2017-09-05 05:26:50 +00:00
										 |  |  | app.post('/upload', function(req, res) { | 
					
						
							| 
									
										
										
										
											2018-03-13 02:51:54 +00:00
										 |  |  | 	console.log(req.files); | 
					
						
							|  |  |  | 	var f = req.files[Object.keys(req.files)[0]]; | 
					
						
							|  |  |  | 	var newpath = path.join(dir, f.name); | 
					
						
							|  |  |  | 	fs.renameSync(f.path, newpath); | 
					
						
							|  |  |  | 	console.log("moved " + f.path + " to " + newpath); | 
					
						
							|  |  |  | 	res.end("wrote to " + f.name); | 
					
						
							| 
									
										
										
										
											2017-09-05 05:26:50 +00:00
										 |  |  | }); | 
					
						
							|  |  |  | app.use(express.static(path.resolve(basepath))); | 
					
						
							|  |  |  | app.use(require('serve-index')(basepath, {'icons':true})); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | app.listen(port, function() { console.log('Serving HTTP on port ' + port); }); | 
					
						
							|  |  |  | 
 |