赞
踩
- from flask import Flask, render_template
- from flask_sqlalchemy import SQLAlchemy
-
- app = Flask(__name__)
- app.config['SQLALCHEMY_DATABASE_URI'] = '你的数据库连接地址'
- db = SQLAlchemy(app)
-
- class User(db.Model):
- id = db.Column(db.Integer, primary_key=True)
- name = db.Column(db.String(20))
- age = db.Column(db.Integer)
-
- @app.route('/')
- def index():
- users = User.query.all()
- return render_template('index.html', users=users)
-
- if __name__ == '__main__':
- app.run()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。