<reponame>FundingCircle/json2html-flask
"""
JSON 2 HTML convertor
=====================

(c) <NAME> 2013
http://softvar.github.io

Original Source Code: https://github.com/softvar/json2html-flask
------------

LICENSE: MIT
--------
"""
# -*- coding: utf-8 -*-

import json
import collections
import html.parser

from flask import json
from flask import Flask
from flask import request
from flask import render_template
from json2html import jsonconv

app = Flask(__name__)

@app.route('/')
def my_form():
    return render_template("index.html")

@app.route('/', methods=['POST'])
def my_form_post():
    """
    receive submitted data and process
    """
    text = request.form['text']
    checkbox = request.form['users']
    style=""
    if(checkbox=="1"):
        style="table table-condensed table-bordered table-hover"
    else:
        style='border="1"'

    #json_input = json.dumps(text)
    try:
        ordered_json = json.loads(text, object_pairs_hook=collections.OrderedDict)
        processed_text = jsonconv.json2html.convert(ordered_json,style)

        html_parser = html.parser.HTMLParser()
        return render_template("index.html", processed_text=html_parser.unescape(processed_text),pro = text)
    except:
        return render_template("index.html",error="Error Parsing JSON ! Please check your JSON syntax",pro=text)



if __name__ == '__main__':
    app.run(debug = True)

"""
JSON 2 HTML convertor
=====================

(c) <NAME> 2013
http://softvar.github.io

Original Source Code: https://github.com/softvar/json2html-flask
------------

LICENSE: MIT
--------
"""
# -*- coding: utf-8 -*-

import json
import collections
import html.parser

from flask import json
from flask import Flask
from flask import request
from flask import render_template
from json2html import jsonconv

app = Flask(__name__)

@app.route('/')
def my_form():
    return render_template("index.html")

@app.route('/', methods=['POST'])
def my_form_post():
    """
    receive submitted data and process
    """
    text = request.form['text']
    checkbox = request.form['users']
    style=""
    if(checkbox=="1"):
        style="table table-condensed table-bordered table-hover"
    else:
        style='border="1"'

    #json_input = json.dumps(text)
    try:
        ordered_json = json.loads(text, object_pairs_hook=collections.OrderedDict)
        processed_text = jsonconv.json2html.convert(ordered_json,style)

        html_parser = html.parser.HTMLParser()
        return render_template("index.html", processed_text=html_parser.unescape(processed_text),pro = text)
    except:
        return render_template("index.html",error="Error Parsing JSON ! Please check your JSON syntax",pro=text)



if __name__ == '__main__':
    app.run(debug = True)
JSON 2 HTML convertor =====================  (c) <NAME> 2013 http://softvar.github.io  Original Source Code: https://github.com/softvar/json2html-flask ------------  LICENSE: MIT -------- # -*- coding: utf-8 -*- receive submitted data and process #json_input = json.dumps(text)