<commit_before>import 'dart:io';

class index {
  String name = 'index';

  void GET() {
  }
}

// simulate urls in web.py
// Set literal is not supported in Dart, so use Map instead of Set
// @see https://code.google.com/p/dart/issues/detail?id=3792
final Map<String, Object> urls = {
  '/': new index()
};

class application {
  // simulate web.application in web.py
  final String HOST = 'localhost';
  final int PORT = 8080;
  Map<String, Object> urls;

  // constructor
  application(Map<String, Object> urls) {
    this.urls = urls;
  }

  void _httpRequestHandler(HttpRequest req) {
    print('${req.method} ${req.uri.path}');

    for (final String url in this.urls.keys) {
      RegExp exp = new RegExp('^${url}\$');
      Iterable<Match> matches = exp.allMatches(req.uri.path);

      //for (Match m in matches) {
      //  String match = m.group(0);
      //  print('matched: ${match}');
      //}
      if (matches.length > 0) {
        req.response.write('Hello, world');
        req.response.close();
        return;
      }
    }
    // 404 not found
    print('not found: ${req.uri.path}');
    req.response.statusCode = HttpStatus.NOT_FOUND;
    req.response.close();
  }<commit_msg>call corresponding method in request hanlder<commit_after>import 'dart:io';

class index {
  String name = 'index';

  void GET(HttpRequest req) {
    req.response.write('Hello, world');
    req.response.close();
  }
}

// simulate urls in web.py
// Set literal is not supported in Dart, so use Map instead of Set
// @see https://code.google.com/p/dart/issues/detail?id=3792
final Map<String, Object> urls = {
  '/': new index()
};

class application {
  // simulate web.application in web.py
  final String HOST = 'localhost';
  final int PORT = 8080;
  Map<String, Object> urls;

  // constructor
  application(Map<String, Object> urls) {
    this.urls = urls;
  }

  void _httpRequestHandler(HttpRequest req) {
    print('${req.method} ${req.uri.path}');

    for (final String urlRegex in this.urls.keys) {
      RegExp exp = new RegExp('^${urlRegex}\$');
      Iterable<Match> matches = exp.allMatches(req.uri.path);

      //for (Match m in matches) {
      //  String match = m.group(0);
      //  print('matched: ${match}');
      //}
      if (matches.length > 0) {
        try {
          if (req.method == 'GET')
            this.urls[urlRegex].GET(req);
          if (req.method == 'POST')
            this.urls[urlRegex].POST(req);
          return;
        } on NoSuchMethodError catch(e) {
          print(e);
        }
      }
    }
    // 404 not found
    print('not found: ${req.uri.path}');
    req.response.statusCode = HttpStatus.NOT_FOUND;
    req.response.close();
  }
{'fraction_non_alphanumeric': 0.15564635958395245, 'fraction_numerical': 0.009658246656760773, 'mean_word_length': 2.5156657963446474, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '884704', 'n_tokens_mistral': 920, 'n_tokens_neox': 889, 'n_words': 221}