Advertisement
ninofelino

Untitled

Dec 7th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. from flask import Flask, render_template, request
  2. from flask.ext.sqlalchemy import SQLAlchemy
  3. #from sqlalchemy import text
  4. from sqlalchemy import create_engine
  5.  
  6. app = Flask(__name__)
  7. app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:odoo@localhost/odoo'
  8. db = SQLAlchemy(app)
  9. engine = create_engine(
  10.     "postgresql://postgres:odoo@localhost/odoo",
  11.     isolation_level="READ UNCOMMITTED"
  12. )
  13.  
  14. @app.route("/")
  15. def index():
  16.     result = engine.execute("select * from product_template")
  17.     names=[]
  18.     for row in result:
  19.         names.append(row)
  20.        
  21.     return render_template('index.html',result=names)
  22.  
  23.  
  24. @app.route("/hello")
  25. def hello():
  26.     return render_template('index.html')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement