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)
    

      

  • 相关阅读:
    07组 Beta冲刺 (2/5)
    第07组 Beta冲刺 (1/5)
    第07组 Alpha冲刺 总结
    ES相关
    集群与分布式
    idea使用总结
    Tomcat配置与启动与访问
    Web基础
    B/S与C/S架构
    一周视频学习总结
  • 原文地址:https://www.cnblogs.com/zheng01/p/7832557.html
Copyright © 2011-2022 走看看