赞
踩
主要代码:
from flask import Flask,request,g,session,flash,redirect,url_for,render_template
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config[‘SQLALCHEMY_DATABASE_URI‘] = ‘mysql+pymysql://root:12345678@localhost/mydb‘
app.config[‘SQLALCHEMY_COMMIT_ON_TEARDOWN‘] = True
app.config[‘SQLALCHEMY_TRACK_MODIFICATIONS‘] = False
db = SQLAlchemy(app)
class User(db.Model):
class User(db.Model):
__tablename__ = ‘user‘
id = db.Column(db.Integer, primary_key=True, autoincrement=True, nullable=False)
name = db.Column(db.String(20), nullable=False)
password = db.Column(db.String(30), nullable=False)
def __repr__(self):
return ‘User:%s‘%self.name
db.create_all()
@app.route(‘/login‘,methods=[‘POST‘,‘GET‘])
def logi
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。