def create_app(): app = Flask(__name__, static_folder=static_dir, template_folder=templates_dir) app.register_blueprint(blueprint=ihome, url_prefix='/ihome') app.register_blueprint(blueprint=house, url_prefix='/house') app.register_blueprint(blueprint=book_blueprint, url_prefix='/booking') app.register_blueprint(blueprint=good_blueprint) app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False # 密钥 app.config['SECRET_KEY'] = 'secret_key' # SESSION类型 app.config['SESSION_TYPE'] = 'redis' # 连接redis app.config['SESSION_REDIS'] = redis.Redis(host='127.0.0.1', port='6379') # 定义前缀 app.config['SESSION_KEY_PREFIX'] = 'ihome' init_ext(app) return app
def create_app(config): app = Flask(__name__, template_folder=templates_dir, static_folder=static_dir) app.register_blueprint(blueprint=person_blueprint, url_prefix='/person') connect("hanghaiwang", host="47.98.172.171", port=27017) app.config.from_object(config) init_ext(app) return app
def create_app(config): app = Flask(__name__, template_folder=TEMPLATE_DIR, static_folder=STATIC_DIR) app.register_blueprint(blueprint=user_bp, url_prefix='/user') app.register_blueprint(blueprint=house_bp, url_prefix='/house') app.register_blueprint(blueprint=order_bp, url_prefix='/order') app.register_blueprint(blueprint=index_bp, url_prefix='/index') app.config.from_object(config) init_ext(app) return app
def create_app(config): app = Flask(__name__, static_folder=static_dir, template_folder=template_dir) app.register_blueprint(blueprint=user_blueprint, url_prefix='/user') app.config.from_object(config) # 初始化对象 init_ext(app) return app
def create_app(): app = Flask(__name__, static_folder=STATIC_DIR, template_folder=TEMPLATES_DIR) app.register_blueprint(blueprint=houses, url_prefix='/house') app.register_blueprint(blueprint=users, url_prefix='/users') app.register_blueprint(blueprint=orders, url_prefix='/orders') app.config.from_object(Config) init_ext(app) return app
def create_app(config): app = Flask(__name__, template_folder=template_dir, static_folder=static_dir) 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.from_object(config) init_ext(app) return app
def create_app(config_name): app = Flask(__name__, static_folder=STATIC_DIR, template_folder=TEMPLATE_DIR) app.config.from_object(configMap[config_name]) # 导入工程的配置文件 # 注册蓝图 app.register_blueprint(blueprint=pro_blue, url_prefix='') app.register_blueprint(blueprint=dom_blue, url_prefix='/domain') # 添加蓝图前缀 url_prefix 为 /domain app.register_blueprint(blueprint=res_blue, url_prefix='/resource') app.register_blueprint(blueprint=ser_blue, url_prefix='/server') # 初始化地方方插件 init_ext(app) return app
def create_app(): app = Flask( __name__, static_folder=STATIC_DIR, template_folder=TEMPLATES_DIR ) # 注册蓝图 app.register_blueprint(blueprint=name, url_prefix='/') # 配置 app.config.from_object(Config) init_ext(app) return app
def create_app(): # template_folder -- 默认访问stu下的templates文件夹 # static_folder -- 默认访问stu下的static文件夹 app = Flask(__name__, template_folder=templates_dir, static_folder=static_dir) app.register_blueprint(blueprint=stu,url_prefix='/stu') # 学生应用与stu蓝图绑定起来,并以/stu前缀与其他应用进行区分 app.register_blueprint(blueprint=grade, url_prefix='/grade') # 班级应用与grade蓝图绑定起来,并以/grade前缀与其他应用进行区分 # 数据库相关配置信息的设定 app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SECRET_KEY'] = 'secret_key' app.debug = True # 显示debugtoolbar工具栏 init_ext(app) # 放置所有的app初始化内容 return app
def create_app(Config): # 实例化对象 app = Flask(__name__, static_folder=STATIC_DIR, template_folder=TEMPLATES_DIR) # 注册蓝图,用户模块的蓝图 # 用户蓝图 app.register_blueprint(blueprint=user_blueprint, url_prefix='/user') # 房源蓝图 app.register_blueprint(blueprint=house_blueprint, url_prefix='/house') # 订单蓝图 app.register_blueprint(blueprint=order_blueprint, url_prefix='/order') app.config.from_object(Config) # 初始化 init_ext(app) return app
def create_app(Config): app = Flask(__name__, template_folder=TEMPLATE_DIR, static_folder=STATIC_DIR) app.register_blueprint(blueprint=user_blueprint, url_prefix='/user') app.register_blueprint(blueprint=house_blueprint, url_prefix='/house') app.config.from_object(Config) app.debug = True init_ext(app) return app
def create_app(): app = Flask(__name__, template_folder=template_dir, static_folder=static_dir) app.debug = True app.register_blueprint(blueprint=stu, url_prefix='/stu') app.register_blueprint(blueprint=grade, url_prefix='/grade') app.config['SQLALCHEMY_DATABASE_URI'] = SQLACHEMY_DATABASE_URI app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SECRET_KEY'] = '<replace with a secret key>' init_ext(app) return app
def create_flask_app(): app = Flask(__name__, static_folder=STATIC_DIRS, template_folder=TEMPLATE_DIRS) app.register_blueprint(blueprint=user_blue, url_prefix='/user') app.register_blueprint(blueprint=product_blue, url_prefix='/product') app.register_blueprint(blueprint=index_blue, url_prefix='') app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SECRET_KEY'] = 'cecret_key' init_ext(app) return app
def create_app(config): app = Flask(__name__, template_folder=TEMPLATES_DIR, static_folder=STATIC_DIR) # app.debug = True app.register_blueprint(blueprint=user, url_prefix='/user') app.register_blueprint(blueprint=house, url_prefix='/house') app.register_blueprint(blueprint=order, url_prefix='/order') # app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI # app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config.from_object(config) init_ext(app) return app
def create_app(config): app = Flask(__name__, template_folder=templates_dir, static_folder=static_dir) app.register_blueprint(blueprint=user, url_prefix="/user") # 数据库相关配置信息的设定 app.config.from_object(config) # 自动以键值对的方式加载配置信息 # 附:from_object源码 # def from_object: # if isinstance(obj, string_types): # obj = import_string(obj) # # for key in dir(obj): # if key.isupper(): # self[key] = getattr(obj, key) # 大写字母的属性它才会进行引入,它引入的方法就是调用通过python标准的api getattr() # 函数,将Myobj的属性改成大写后读取Myobj的NAME属性并获取其值正常 init_ext(app) # 放置所有的app初始化内容 return app
def create_app(): app = Flask(__name__, static_folder=STATIC_DIR, template_folder=TEMPLATES_DIR) # 配置 app.config.from_object(Config) # 注册蓝图 app.register_blueprint(blueprint=user_blueprint, url_prefix='/user') app.register_blueprint(blueprint=house_blueprint, url_prefix='/house') app.register_blueprint(blueprint=order_blueprint, url_prefix='/order') # 初始化各种第三方库 init_ext(app) # 登录跳转 login_manager.session_protection = 'strong' # 当登录认证不通过,则跳转到该地址 login_manager.login_view = 'user.login' return app
#coding=utf-8 from flask import Flask from flask_script import Manager from app.house_views import house_blue from app.order_views import order_blue from app.user_views import user_blue from utils.functions import init_ext app = Flask(__name__) app.register_blueprint(blueprint=user_blue, url_prefix='/user') app.register_blueprint(blueprint=house_blue, url_prefix='/house') app.register_blueprint(blueprint=order_blue, url_prefix='/order') app.secret_key = 'jiangxiucheng' # 配置config文件 # app.config.from_object(Config) app.config[ 'SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:[email protected]:3306/ihome' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False # 初始化 init_ext(app) manage = Manager(app) if __name__ == '__main__': manage.run()