def create_app(): # 创建flask对象app app = Flask(__name__, static_folder=static_folder, template_folder=template_folder) # 创建总路由 app.register_blueprint(user_blueprint, url_prefix='/user') app.register_blueprint(house_blueprint, url_prefix='/house') app.register_blueprint(order_blueprint, url_prefix='/order') # 配置数据库 app.config['SQLALCHEMY_DATABASE_URI'] = get_sqlalchemy_uri(MYSQL_DATABASE) app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db.init_app(app) # 配置redis-->session app.config['SESSION_TYPE'] = 'redis' app.config['SESSION_REDIS'] = redis.Redis(host=REDIS_DATABASE['HOST'], port=REDIS_DATABASE['PORT']) se = Session() se.init_app(app) # 配置debug模式 # app.config['SECRET_KEY'] = 'secret_key' # app.debug = True # bar = DebugToolbarExtension() # bar.init_app(app) return app
def create_app(): app = Flask(__name__, static_folder=static_folder, template_folder=template_folder) @app.route('/') def index(): return render_template('index.html') # 注册蓝图 app.register_blueprint(user_blueprint, url_prefix='/user') app.register_blueprint(house_blueprint, url_prefix='/house') app.register_blueprint(order_blueprint, url_prefix='/order') # 设置数据库的配置 app.config['SQLALCHEMY_DATABASE_URI'] = get_sqlalchemy_uri(MYSQL_DATABASE) app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False # redis --> session - 通过redis启动session app.config['SESSION_TYPE'] = 'redis' app.config['SESSION_REDIS'] = redis.Redis(host=REDIS_DATABASE['HOST'], port=REDIS_DATABASE['PORT']) app.config['SECRET_KEY'] = 'secret_key' # app.debug = True db.init_app(app) se = Session() se.init_app(app) # bar = DebugToolbarExtension() # bar.init_app(app) return app
class Conf(): # 配置mysql数据库连接 SQLALCHEMY_DATABASE_URI = get_sqlalchemy_uri(DATABASE) SQLALCHEMY_TRACK_MODIFICATIONS = False # 配置teardown执行 PRESERVE_CONTEXT_ON_EXCEPTION = False # 配置secret key SECRET_KEY = '1234567890ZQAWXSECDRVFTBGYNHUMJIKLOP'
class Conf: # 配置mysql数据库 SQLALCHEMY_DATABASE_URI = get_sqlalchemy_uri(DATABASE) SQLALCHEMY_TRACK_MODIFICATIONS = False PRESERVE_CONTEXT_ON_EXCEPTION = False SECRET_KEY = '1234567890qwertyuiopasdfghjklzxcvbnm' # 配置redis数据库 SESSION_TYPE = 'redis' SESSION_REDIS = redis.Redis(host=REDIS_DATABASE['HOST'], port=REDIS_DATABASE['PORT'])
class Conf(): SQLALCHEMY_DATABASE_URI = get_sqlalchemy_uri(DATABASE) SQLALCHEMY_TRACK_MODIFICATIONS = False PRESERVE_CONTEXT_ON_EXCEPTION = False SECRET_KEY = '1212' # 设置qq邮箱服务器地址 MAIL_SERVER = 'smtp.qq.com' # 设置是否启用传输层安全协议 MAIL_USE_TLS = True # 设置传输邮箱地址 MAIL_USERNAME = '******' # qq邮箱输入授权码 MAIL_PASSWORD = '******'
class Conf(): # 配置连接数据库uri SQLALCHEMY_DATABASE_URI = get_sqlalchemy_uri(DATABASE) # 解决连接数据库时出现的一个警告 SQLALCHEMY_TRACK_MODIFICATIONS = False # 配置执行teardown_request PRESERVE_CONTEXT_ON_EXCEPTION = False SECRET_KEY = 'QAZXSW123EDC456' # 配置连接Redis,用于存储session数据 SESSION_TYPE = 'redis' # 配置Redis连接地址 SESSION_REDIS = redis.Redis(host='172.18.152.165', password='******', port=6379)
def create_app(): # 写法一 目的获取模板和静态资源路径 # app = Flask(__name__, # static_folder='../static', # template_folder='../tempaltes') # 写法二 app = Flask( __name__, static_folder=static_dir, template_folder=template_dir, ) # 注册蓝图 app.register_blueprint(user_blueprint, url_prefix='/my_user') app.register_blueprint(house_blueprint, url_prefix='/house') app.register_blueprint(order_blueprint, url_prefix='/order') # 设置数据库 app.config['SQLALCHEMY_DATABASE_URI'] = get_sqlalchemy_uri(MYSQL_DATABASE) app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SESSION_TYPE'] = 'redis' app.config['SESSION_REDIS'] = redis.Redis(host=REDIS_DATABASE['HOST'], port=REDIS_DATABASE['PORT']) app.config['SECRET_KEY'] = '123456' app.debug = True # bar = DebugToolbarExtension() se = Session() # bar.init_app(app) se.init_app(app) db.init_app(app) return app
class Conf(): SQLALCHEMY_DATABASE_URI = get_sqlalchemy_uri(DATABASE) SQLALCHEMY_TRACK_MODIFICATIONS= False PRESERVE_CONTEXT_ON_EXCEPTION = False SECRET_KEY = 'fkhqjhyr38r1khgjr1h2r4'
class Conf(): SQLALCHEMY_DATABASE_URI = get_sqlalchemy_uri(DATABASE) SQLALCHEMY_TRACK_MODIFICATIONS = False PRESERVE_CONTEXT_ON_EXCEPTION = False SECRET_KEY = 'qwertyuiopasdfghjklzxcvbnm1234567890'