<commit_before>#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
import sys

#import all modules in glpi.objects
from glpi.objects import *

app = Flask(__name__, static_url_path = "")

@app.errorhandler(400)
def not_found(error):
    return make_response(jsonify( { 'error': 'Bad request' } ), 400)

@app.errorhandler(404)
def not_found(error):
    return make_response(jsonify( { 'error': 'Not found' } ), 404)

@app.route('/api/v1.0/objects/<urlobject>', methods = ['GET'])
def get_all(urlobject):
    modulename = 'glpi.objects.'+urlobject
    if not modulename in sys.modules:
        return make_response(jsonify( { 'error': 'Not found' } ), 404)
    mymodule = sys.modules[modulename]
    return jsonify( { urlobject: mymodule.getall() } )

@app.route('/api/v1.0/objects/<urlobject>/<int:id>', methods = ['GET'])
def get_id(urlobject, id):
    if (module_exists(urlobject)):
        i = __import__(urlobject)
        return jsonify( { 'computers': i.getid(id) } )


def module_exists(module_name):
    try:
        __import__(module_name)
    except ImportError:
        return False
    else:
        return True

if __name__ == '__main__':
    app.run(debug = True)<commit_msg>CHange REST for manage better id and index + pages<commit_after>#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
import sys

#import all modules in glpi.objects
from glpi.objects import *

app = Flask(__name__, static_url_path = "")

@app.errorhandler(400)
def not_found(error):
    return make_response(jsonify( { 'error': 'Bad request' } ), 400)

@app.errorhandler(404)
def not_found(error):
    return make_response(jsonify( { 'error': 'Not found' } ), 404)

@app.route('/api/v1.0/objects/<urlobject>', methods = ['GET'])
@app.route('/api/v1.0/objects/<urlobject>/index', methods = ['GET'])
@app.route('/api/v1.0/objects/<urlobject>/index/<pagenum>', methods = ['GET'])
def get_all(urlobject, pagenum = 0):
    modulename = 'glpi.objects.'+urlobject
    if not modulename in sys.modules:
        return make_response(jsonify( { 'error': 'Not found' } ), 404)
    mymodule = sys.modules[modulename]
    return jsonify( { urlobject: mymodule.getall() } )

@app.route('/api/v1.0/objects/<urlobject>/id/<int:id>', methods = ['GET'])
def get_id(urlobject, id):
    if (module_exists(urlobject)):
        i = __import__(urlobject)
        return jsonify( { 'computers': i.getid(id) } )


def module_exists(module_name):
    try:
        __import__(module_name)
    except ImportError:
        return False
    else:
        return True

if __name__ == '__main__':
    app.run(debug = True)
{'fraction_non_alphanumeric': 0.1509220925856229, 'fraction_numerical': 0.01618366578848325, 'mean_word_length': 4.005649717514125, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '1402628', 'n_tokens_mistral': 938, 'n_tokens_neox': 911, 'n_words': 205}