Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Flask application displaying list of items from SQL database as text

@app.route('/')
def index():
    try:
        products = Product.query.all()
        return render_template('index.html', products=products)
    except Exception as e:
        error_text = "<p>The error:<br>" + str(e) + "</p>"
        hed = '<h1>Something is broken.</h1>'
        return hed + error_text
 
PREVIOUS NEXT
Tagged: #Flask #application #displaying #list #items #SQL #database #text
ADD COMMENT
Topic
Name
4+9 =