<commit_before>var request = require('request');
var fs = require('fs');
var path = require('path');
var util = require('util');

var ServiceSettings = require('../service-settings');

function Service(main) {
    this._settings = main.settings;
    Service.super_.call(this);

    this._name = "scrup";
    this.name = "Scrup";
    this.description = "Scrup compatible uploader";

    this.settings = [
        {
            name: 'Upload URL',
            key: 'upload_url',
            type: 'text',
            password: <PASSWORD>,
            default: '',
            helpText: 'The URL to recieve the POST request'
        }
    ];

    this.loadSettings();
}

util.inherits(Service, ServiceSettings);

Service.prototype.upload = function(filepath, callback) {
    var _self = this;

    if (!_self.getSetting('upload_url')) return window.alert('No url configured for upload');

    request.post({
        url: _self.getSetting('upload_url'),
        body: fs.readFileSync(filepath)
    }, function(err, response, body) {
        if (err) {
            window.alert('error: ' + err);
            return;
        }

        if (response.statusCode != 200) {
            window.alert('error: server returned status code ' + response.statusCode);
            return;
        }

        callback(body);
    });
}

module.exports = Service;<commit_msg>Accept any 2xx response as valid<commit_after>var request = require('request');
var fs = require('fs');
var path = require('path');
var util = require('util');

var ServiceSettings = require('../service-settings');

function Service(main) {
    this._settings = main.settings;
    Service.super_.call(this);

    this._name = "scrup";
    this.name = "Scrup";
    this.description = "Scrup compatible uploader";

    this.settings = [
        {
            name: 'Upload URL',
            key: 'upload_url',
            type: 'text',
            password: <PASSWORD>,
            default: '',
            helpText: 'The URL to recieve the POST request'
        }
    ];

    this.loadSettings();
}

util.inherits(Service, ServiceSettings);

Service.prototype.upload = function(filepath, callback) {
    var _self = this;

    if (!_self.getSetting('upload_url')) return window.alert('No url configured for upload');

    request.post({
        url: _self.getSetting('upload_url'),
        body: fs.readFileSync(filepath)
    }, function(err, response, body) {
        if (err) {
            window.alert('error: ' + err);
            return;
        }

        if (response.statusCode < 200 || response.statusCode >= 300) {
            window.alert('error: server returned status code ' + response.statusCode);
            return;
        }

        callback(body);
    });
}

module.exports = Service;
{'fraction_non_alphanumeric': 0.1378809869375907, 'fraction_numerical': 0.00362844702467344, 'mean_word_length': 2.3580998781973204, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '5500113', 'n_tokens_mistral': 798, 'n_tokens_neox': 770, 'n_words': 186}