Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Start Butterfly for User
var spawn = require("child_process").spawn;
var process = spawn('butterfly.server.py',["--port=57575", "--unsecure"]);
console.log('Starting Butterfly Server on port 57575...');
process.stdout.on('data', function(chunk){
var textChunk = chunk.toString('utf8');
console.log(textChunk);
});
// Start WebServer
const express = require('express');
var SocketIOFileUpload = require('socketio-file-upload');
var app = express().use(express.static(__dirname + '/')).use(SocketIOFileUpload.router);
const http = require('http').Server(app);
const socket = require('socket.io')(http);
http.listen(3000, function(){
console.log('Listening on http://127.0.0.1:3000');
});
// ------------------ upload start ------------------ //
var io = socket.listen(http);
io.sockets.on("connection", function(socket){
// Make an instance of SocketIOFileUpload and listen on this socket:
var uploader = new SocketIOFileUpload();
uploader.dir = "uploads";
import socket from './socket';
import SocketIOFileUpload from 'socketio-file-upload';
let siofu = new SocketIOFileUpload(socket);
// https://github.com/vote539/socketio-file-upload#instanceusetext--false
siofu.useText = true;
export default siofu;
const compression = require('compression');
const bodyParser = require('body-parser');
const path = require('path');
var siofu = require("socketio-file-upload");
var generator = require('./backend/generator.js');
const config = require('../config.json');
var app = express();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var id = 0;
app.use(compression());
app.use(siofu.router);
var errorHandler;
io.on('connection', function(socket){
socket.on('disconnect', function () {
});
id = id + 1;
socket.connId = id;
var uploader = new siofu();
uploader.dir = path.join(__dirname, '..', 'uploads/connection-' + id.toString());
socket.fileUpload = false;
uploader.listen(socket);
uploader.on('error', function(err) {
console.log(err);
});