<commit_before>library ping;

import 'package:start/start.dart';
import 'package:http/http.dart' as http;
import 'package:args/args.dart';

/**
 * Starts the ping server.
 */
void startPingServer(url, port) {

  int errorCounter = 0;

  start(host: "0.0.0.0", port: port).then((app) {
    app.get("/ping/:length").listen((req) async {
      int len = int.parse(req.param('length'), onError: (len) {
        print("A message of undefined length has been requested ('$len'). Switching to standard length 4 ('pong')");
        return 4;
      });

      var tries = 0;

      while (tries < 10) {
        try {
          var response = await http.get("$url/pong/$len");
          req.response.status(200);
          req.response.send(response.body);
        } catch (e) {
          print(e);
          print("But we will retry.");
          tries++;
        }
      }

      if (tries >= 10) {
        req.response.status(503);
        req.response.send("Pong server is not answering");
        print("$errorCounter non resolveable problem");
        errorCounter++;
      }

      /*.then((response) {
        req.response.status(200);
        req.response.send(response.body);
      }).catchError((err) {
        print(err);
        req.response.status(503);
        req.response.send("Pong server is not answering");
      });*/
    });

    print("Ping-Server is up and running, Listening on port $port");
    print("Pong-Server assumed to be reachable at $url");

  });
}

/**
 * Entrypoint to start the ping relay server without docker.
 */
void main(args) {
  // Command line options for the ping server
  final options = new ArgParser();
  options.addOption('url', abbr: 'u', defaultsTo: 'http://localhost:4040', help: 'used to specify the pong url');
  options.addOption('port', abbr: 'p', defaultsTo: '8080', help: 'port number');<commit_msg>bugfix<commit_after>library ping;

import 'package:start/start.dart';
import 'package:http/http.dart' as http;
import 'package:args/args.dart';

/**
 * Starts the ping server.
 */
void startPingServer(url, port) {

  int errorCounter = 0;

  start(host: "0.0.0.0", port: port).then((app) {
    app.get("/ping/:length").listen((req) async {
      int len = int.parse(req.param('length'), onError: (len) {
        print("A message of undefined length has been requested ('$len'). Switching to standard length 4 ('pong')");
        return 4;
      });

      var tries = 0;

      while (tries < 10) {
        try {
          var response = await http.get("$url/pong/$len");
          req.response.status(200);
          req.response.send(response.body);
          req.response.close();
        } catch (e) {
          print(e);
          print("But we will retry.");
          tries++;
        }
      }

      if (tries >= 10) {
        req.response.status(503);
        req.response.send("Pong server is not answering");
        req.response.close();
        print("$errorCounter non resolveable problem");
        errorCounter++;
      }

      /*.then((response) {
        req.response.status(200);
        req.response.send(response.body);
      }).catchError((err) {
        print(err);
        req.response.status(503);
        req.response.send("Pong server is not answering");
      });*/
    });

    print("Ping-Server is up and running, Listening on port $port");
    print("Pong-Server assumed to be reachable at $url");

  });
}

/**
 * Entrypoint to start the ping relay server without docker.
 */
void main(args) {
  // Command line options for the ping server
  final options = new ArgParser();
  options.addOption('url', abbr: 'u', defaultsTo: 'http://localhost:4040', help: 'used to specify the pong url');
  options.addOption('port', abbr: 'p', defaultsTo: '8080', help: 'port number');
{'fraction_non_alphanumeric': 0.15827338129496402, 'fraction_numerical': 0.01705302424726885, 'mean_word_length': 2.531514581373471, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3043160', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1137, 'n_words': 305}