<commit_before>const _ = require('lodash');
const jsonfile = require('jsonfile');
const path = require('path');
const express = require('express');
const webpack = require('webpack');
const config = require('../webpack.config.dev');

const app = express();
const compiler = webpack(config);

const networks = [
  {
    path: 'eta_3_hidden_5.json',
    hiddenNodes: 5,
    eta: 3.0,
    activation: 'Sigmoid',
    accuracy: '87%'
  },
  {
    path: 'eta_3_hidden_10.json',
    hiddenNodes: 10,
    eta: 3.0,
    activation: 'Sigmoid',
    accuracy: '90%'
  },
  {
    path: 'eta_3_hidden_20.json',
    hiddenNodes: 20,
    eta: 3.0,
    activation: 'Sigmoid',
    accuracy: '93%'
  },
  {
    path: 'eta_3_hidden_30.json',
    hiddenNodes: 30,
    eta: 3.0,
    activation: 'Sigmoid',
    accuracy: '94%'
  },
  {
    path: 'eta_.3_hidden_30.json',
    hiddenNodes: 30,
    eta: 0.3,
    activation: 'Sigmoid',
    accuracy: '82%'
  },
  {
    path: 'eta_3_hidden_20_15.json',
    hiddenNodes: '20, 15',
    eta: 3,
    activation: 'Sigmoid',
    accuracy: '93%'
  },
];

app.use(require('webpack-dev-middleware')(compiler, {
  noInfo: true,
  publicPath: config.output.publicPath
}));

app.use(require('webpack-hot-middleware')(compiler));

// app.get('/awesome', (req, res) => {
//   jsonfile.readFile(path.join(__dirname, 'json', 'mnist', 'testing_0-499'), (err, file) => {
//     res.send(file);
//   });
// });

app.get('/network', (req, res) => {
  res.send(networks);
});

app.get('/network/:id', function (req, res) {
  const filename = req.params.id;

  // Make sure this is a valid name hard coded above, do not want to allow any
  // file to be returned with path.join below. Should be done better, but this
  // should be secure for now.
  const isValidPath = _.find(networks, { path: filename });
  if (!isValidPath) {
    return res.status(500).send('Network does not exist');
  }

  jsonfile.readFile(path.join(__dirname, 'json', 'networks', filename), (err, file) => {
    if (err) {
      return res.status(500).send(err);
    }
    res.send(file);
  });
});

app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname, '..', 'index.html'));
});

app.listen(3000, 'localhost', (err) => {
  if (err) {
    console.log(err);
    return;
  }

  console.log('Listening at http://localhost:3000');
});<commit_msg>update port<commit_after>const _ = require('lodash');
const jsonfile = require('jsonfile');
const path = require('path');
const express = require('express');
const webpack = require('webpack');
const config = require('../webpack.config.dev');

const app = express();
const compiler = webpack(config);

const networks = [
  {
    path: 'eta_3_hidden_5.json',
    hiddenNodes: 5,
    eta: 3.0,
    activation: 'Sigmoid',
    accuracy: '87%'
  },
  {
    path: 'eta_3_hidden_10.json',
    hiddenNodes: 10,
    eta: 3.0,
    activation: 'Sigmoid',
    accuracy: '90%'
  },
  {
    path: 'eta_3_hidden_20.json',
    hiddenNodes: 20,
    eta: 3.0,
    activation: 'Sigmoid',
    accuracy: '93%'
  },
  {
    path: 'eta_3_hidden_30.json',
    hiddenNodes: 30,
    eta: 3.0,
    activation: 'Sigmoid',
    accuracy: '94%'
  },
  {
    path: 'eta_.3_hidden_30.json',
    hiddenNodes: 30,
    eta: 0.3,
    activation: 'Sigmoid',
    accuracy: '82%'
  },
  {
    path: 'eta_3_hidden_20_15.json',
    hiddenNodes: '20, 15',
    eta: 3,
    activation: 'Sigmoid',
    accuracy: '93%'
  },
];

app.use(require('webpack-dev-middleware')(compiler, {
  noInfo: true,
  publicPath: config.output.publicPath
}));

app.use(require('webpack-hot-middleware')(compiler));

// app.get('/awesome', (req, res) => {
//   jsonfile.readFile(path.join(__dirname, 'json', 'mnist', 'testing_0-499'), (err, file) => {
//     res.send(file);
//   });
// });

app.get('/network', (req, res) => {
  res.send(networks);
});

app.get('/network/:id', function (req, res) {
  const filename = req.params.id;

  // Make sure this is a valid name hard coded above, do not want to allow any
  // file to be returned with path.join below. Should be done better, but this
  // should be secure for now.
  const isValidPath = _.find(networks, { path: filename });
  if (!isValidPath) {
    return res.status(500).send('Network does not exist');
  }

  jsonfile.readFile(path.join(__dirname, 'json', 'networks', filename), (err, file) => {
    if (err) {
      return res.status(500).send(err);
    }
    res.send(file);
  });
});

app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname, '..', 'index.html'));
});


app.listen(process.env.PORT || 3000, 'localhost', (err) => {
  if (err) {
    console.log(err);
    return;
  }

  console.log('Listening at http://localhost:3000');
});
{'fraction_non_alphanumeric': 0.19072054735941843, 'fraction_numerical': 0.031216591832371177, 'mean_word_length': 3.2106210621062106, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5167848', 'n_tokens_mistral': 1802, 'n_tokens_neox': 1709, 'n_words': 372}