<commit_before>#!/usr/bin/env python
import os

from flask import Flask, jsonify, request
from flask.ext.iniconfig import INIConfig

from routing import JumpGraphProvider as jgp
from networkx import shortest_path

app = Flask(__name__)
INIConfig(app)

config_file = os.path.join(os.path.dirname(__file__), 'server.ini')

with app.app_context():
    app.config.from_inifile('server.ini')


@app.route('/routes/regions/shortest/', methods=['GET'])
def shortest_region_route():
    fromID = request.args.get('from', type=int)
    toID = request.args.get('to', type=int)

    res = shortest_path(jgp().region_jump_graph, fromID, toID)
    return jsonify({'route': res})

if __name__ == '__main__':
    app.run()<commit_msg>Added /systems route to list systems<commit_after>#!/usr/bin/env python
"""Main Flask module. Execute this file to start the HTTP server"""
import os

from flask import Flask, jsonify, request
from flask.ext.iniconfig import INIConfig

from dbclient import api as universe
from routing import JumpGraphProvider as jgp
from networkx import shortest_path

app = Flask(__name__)
INIConfig(app)

config_file = os.path.join(os.path.dirname(__file__), 'server.ini')

with app.app_context():
    app.config.from_inifile('server.ini')


@app.route('/routes/regions/shortest/', methods=['GET'])
def shortest_region_route():
    """Return shortest route between two regions"""
    fromID = request.args.get('from', type=int)
    toID = request.args.get('to', type=int)

    res = shortest_path(jgp().region_jump_graph, fromID, toID)
    return jsonify({'route': res})


@app.route('/systems', methods=['GET'])
def list_systems():
    """Return data about all the static (non-wormhole) systems in the
    EVE Online universe

    Examples:

      $ curl http://127.0.0.1:5000/systems
      {
        "systems": [
          {
            "border": true,
            "constellation": false,
            "constellationID": 20000001,
            ...
          },
          {
           "border": true,
            "constellation": false,
            "constellationID": 20000002,
            ...
          }
          ...
        ]
      }

    """
    # TODO: pagination
    systems = universe.list_systems()

    res = []
    for system in systems:
        res.append(system.as_dict())

    return jsonify({'systems': res})

if __name__ == '__main__':
    app.run()
{'fraction_non_alphanumeric': 0.13459915611814346, 'fraction_numerical': 0.010970464135021098, 'mean_word_length': 3.0668953687821614, 'pattern_counts': {'":': 7, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '1433428', 'n_tokens_mistral': 798, 'n_tokens_neox': 738, 'n_words': 181}