Skip to content Skip to sidebar Skip to footer

RESTful API - Display Returned Json In Html Table

I'm trying to do a restful api in flask and python. Here's my code: from flask import Flask, jsonify, request, render_template from flask_restful import Api, Resource app = Flask(

Solution 1:

in your application return the following:

return Response(render_template('test.html', result=test, mimetype='text/html'))

and in test.html

<!DOCTYPE html>
<html>
<head></head>
<body>
    <table>
        {% for key, value in result.iteritems() %}

        <tr>
            <th> {{ key }} </th>
            <td> {{ value }} </td>
        </tr>
        {% endfor %}
    </table>
</body>
</html>

this was my output: enter image description here


Post a Comment for "RESTful API - Display Returned Json In Html Table"