예제 #1
0
def show(show_type='json'):

    # SE PIDEN LOS DATOS DE LA URL
    limit_str = str(request.args.get('limit'))
    offset_str = str(request.args.get('offset'))

    limit = 0
    offset = 0

    if(limit_str is not None) and (limit_str.isdigit()):
        limit = int(limit_str)

    if(offset_str is not None) and (offset_str.isdigit()):
        offset = int(offset_str)

    if show_type == 'json':
        data = persona.report(limit=limit, offset=offset, dict_format=True)
        return jsonify(data)
    
    elif show_type == 'table':
        data = persona.report(limit=limit, offset=offset, dict_format=True)
        return html_table(data)

    else:
        data = persona.report(limit=limit, offset=offset, dict_format=True)
        return jsonify(data)
예제 #2
0
def personas():
    try:
        # Mostrar todas las personas
        result = persona.report()
        return jsonify(result)
    except:
        return jsonify({'trace': traceback.format_exc()})
예제 #3
0
def personas_tabla():
    try:
        
        data = persona.report()
         
        return jsonify(data)
    except:
        return jsonify({'trace': traceback.format_exc()})
예제 #4
0
def personas():
    try:
        # Alumno:
        # Implementar la captura de limit y offset de los argumentos
        # de la URL
        # limit = ...
        # offset = ....

        # Debe verificar si el limit y offset son válidos cuando
        # no son especificados en la URL

        limit = 0
        offset = 0

        result = persona.report(limit=limit, offset=offset)
        return jsonify(result)
    except:
        return jsonify({'trace': traceback.format_exc()})
예제 #5
0
def grafico():

    data = persona.report()
    print(data)
    nac_nombre, nac_cant = persona.graphics_factory(data)

    try:
        # confección de gráfico
        fig = plt.figure()
        fig.suptitle('Nacionalidades', fontsize=16)
        ax = fig.add_subplot()
        ax.bar(nac_nombre, nac_cant, label='Nacionalidad')
        ax.legend()
        # plt.show()

        # convertir gráfico en imagen
        output = io.BytesIO()
        FigureCanvas(fig).print_png(output)
        return Response(output.getvalue(), mimetype='image/png')
    except:
        return jsonify({'trace': traceback.format_exc()})
예제 #6
0
def comparativa():
    try:
        # Mostrar todos los registros en um gráfico
        result = '''<h3>Implementar una función en persona.py
                    nationality_review</h3>'''
        result += '''<h3>Esa funcion debe devolver los datos que necesite
                    para implementar el grafico a mostrar</h3>'''

        # Tabla HTML, header y formato
        result += '<table border="1">'
        result += '<thead cellpadding="1.0" cellspacing="1.0">'
        result += '<tr>'
        result += '<th>Nombre</th>'
        result += '<th>Edad</th>'
        result += '<th>Nacionalidad</th>'
        result += '</tr>'

        data = persona.report()
        print(data)

        # return (result)

        for row in data:

            # Fila de una tabla HTML
            result += '<tr>'
            result += '<td>' + str(row['name']) + '</td>'
            result += '<td>' + str(row['age']) + '</td>'
            result += '<td>' + str(row['nationality']) + '</td>'
            result += '</tr>'

        # Fin de la tabla HTML
        result += '</thead cellpadding="0" cellspacing="0" >'
        result += '</table>'

        return (result)

    except:
        return jsonify({'trace': traceback.format_exc()})
예제 #7
0
def personas():
    try:
        # Alumno:
        # Implementar la captura de limit y offset de los argumentos
        # de la URL
        # limit = ...
        # offset = ....

        # Debe verificar si el limit y offset son válidos cuando
        # no son especificados en la URL

        # Alumno: Pasarle al metodo report los valores de limit y offset
        data = persona.report()

        result = '''<h3>Alumno: Implementar la llamada
                    al HTML tabla.html
                    con render_template, recuerde pasar
                    data como parámetro</h3>'''
        # Sacar esta linea cuando haya implementado el return
        # con render template
        return result
    except:
        return jsonify({'trace': traceback.format_exc()})