zoukankan      html  css  js  c++  java
  • 连接mysql数据库,创建用户模型

    from flask import Flask ,render_template
    from flask_sqlalchemy import SQLAlchemy
    import config
    app = Flask(__name__)
    app.config.from_object(config)
    db=SQLAlchemy(app)
    class User(db.Model):
        __tablename__ = 'user'
        id = db.Column(db.Integer,primary_key=True,autoincrement=True)
        username = db.Column(db.String(20),nullable=False)
        password = db.Column(db.String(20),nullable=False)
    
    db.create_all()
    @app.route('/')
    def lx():
        return render_template('lx3.html')
    @app.route('/login/',methods=['GET','POST'])
    def login():
        return render_template('lx2.html')
    @app.route('/regist')
    def regist():
        return render_template('lx.html')
    @app.route('/fabu')
    def fabu():
        return render_template('fabu.html')
    
    if __name__ == '__main__':
        app.run(debug=True)
    

      

  • 相关阅读:
    正则表达式收藏
    c#mvc实现登录
    jQuery获取URL中的参数
    TortoiseSVN新人使用指南
    CheckBox获取一组及全选
    day45
    day44
    day43
    day43
    day42
  • 原文地址:https://www.cnblogs.com/zheng01/p/7832557.html
Copyright © 2011-2022 走看看