def index(page=1): try: m_sections = Section() list_sections = m_sections.all_data(page, app.config['LISTINGS_PER_PAGE']) # html or Json response if request_wants_json(): return jsonify([{ 'id': d.id, 'title_en_US': d.title_en_US, 'description_en_US': d.description_en_US, 'title_fr_FR': d.title_fr_FR, 'description_fr_FR': d.description_fr_FR } for d in list_sections.items]) else: return render_template("sections/index.html", list_sections=list_sections, app=app) except Exception, ex: print("------------ ERROR ------------\n" + str(ex.message))