You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							24 lines
						
					
					
						
							827 B
						
					
					
				
			
		
		
	
	
							24 lines
						
					
					
						
							827 B
						
					
					
				| var http = require("http");
 | |
| var Converter = require("../../core/Converter.js");
 | |
| function startWebServer (args) {
 | |
|     args = args || {};
 | |
|     var serverArgs = {
 | |
|         port: args.port || '8801',
 | |
|         urlpath: args.urlpath || '/parseCSV'
 | |
|     };
 | |
|     var server = http.createServer();
 | |
|     server.on("request", function(req, res){
 | |
|         if (req.url === serverArgs.urlpath && req.method === "POST"){
 | |
|             req.pipe(new Converter({constructResult:false})).pipe(res);
 | |
|         } else {
 | |
|             res.end("Please post data to: " + serverArgs.urlpath);
 | |
|         }
 | |
|     });
 | |
| 
 | |
|     server.listen(serverArgs.port);
 | |
|     console.log("CSV Web Server Listen On:" + serverArgs.port);
 | |
|     console.log("POST to " + serverArgs.urlpath + " with CSV data to get parsed.");
 | |
|     return server;
 | |
| }
 | |
| module.exports.startWebServer = startWebServer;
 |