<commit_before>const express = require('express');
const app = express();

const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('db.sqlite3');


app.get('/', function (req, res) {
  res.send('a');
});

// put successfull signal
app.get('/r/:rId', function (req, res) {
  const rId = req.params.rId;

  res.send("Ok. " + rId);
});

app.post('/new', function (req, res) {
  let url = req.body.url;
  // TODO : query parser to json
  let form_data = req.body.form_data;

  db.serialize(function () {
    const insert = db.prepare("insert into valid_xss_checker (url, form_data) values (?, ?)");
    insert.run(url, form_data);
    insert.finalize();
    db.each("select last_insert_rowid() from valid_xss_checker limit 1;", function (err, row) {
      let response = Object();
      response.rId = row['last_insert_rowid()'];
      response.url = url;
      response.form_data = form_data;
      res.send(JSON.stringify(response));
    });
  });
});

const server = app.listen(8080, function () {
  const host = server.address().address;
  const port = server.address().port;
  console.log("http://%s:%s", host, port);
});<commit_msg>Add make new xss function and make update function<commit_after>const express = require('express');
const app = express();

const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('db.sqlite3');

let bodyParser = require('body-parser')
app.use(bodyParser.urlencoded({ extended: false }));

app.get('/', function (req, res) {
  res.send('Hello world!');
});

// put successfull signal
// update count
app.get('/r/:rId', function (req, res) {
  const rId = req.params.rId;

  db.serialize(function () {
    let response = Object();
    db.run("update valid_xss_checker set count=count+1 where rId=?", rId);
    response.rId = rId;
    response.status = "success";
    res.send(response);
  });
});

app.post('/new', function (req, res) {
  let url = "";
  if (req.body.url) {
    url = req.body.url
  } else {
    url = "http://default.com/";
  }
  // TODO : query parser to json
  let form_data = {};
  if (req.body.form_data) {
    form_data = req.body.form_data;
  } else {
    form_data = '{"a": "TEST"}';
  }

  try {
    db.serialize(function () {
      const insert = db.prepare("insert into valid_xss_checker (url, form_data) values (?, ?)");
      insert.run(url, form_data);
      insert.finalize();
      db.each("select last_insert_rowid() from valid_xss_checker limit 1;", function (err, row) {
        let response = Object();
        response.rId = row['last_insert_rowid()'];
        response.url = url;
        response.form_data = form_data;
        res.send(response);
      });
    });
  } catch (exception) {
    res.send("Error !");
  }
});

const server = app.listen(8080, function () {
  const host = server.address().address;
  const port = server.address().port;
  console.log("run => http://%s:%s", host, port);
});
{'fraction_non_alphanumeric': 0.1792323509252913, 'fraction_numerical': 0.0065113091158327625, 'mean_word_length': 3.376311844077961, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 4, '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': '7668165', 'n_tokens_mistral': 995, 'n_tokens_neox': 981, 'n_words': 227}