Example #1
0
def create_app(env):
    app = Flask(__name__)
    app.config.from_object(envs.get(env))
    init_ext(app)
    init_view(app=app)

    return app
Example #2
0
def create_app():
    app = Flask(__name__)
    #uri 数据库+驱动(py中有的数据库比如sqlite不需要写驱动)://用户名:密码@主机:端口/数据库名
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///sqlite.db'
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    init_model(app)
    init_view(app)
    return app
Example #3
0
def create_app():
    app = Flask(__name__)
    #url全格式  数据库+驱动://用户名:密码@主机:端口/具体哪个库
    app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///sqlite.db"
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

    init_ext(app)
    init_view(app)
    return app
Example #4
0
def create_app(env):
    app = Flask(__name__)
    # 加载配置
    app.config.from_object(envs.get(env))
    # 初始化第三方扩展库
    init_ext(app=app)
    # 初始化路由
    init_view(app=app)

    return app
Example #5
0
def create_app(env):
    app = Flask(__name__)
    # app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///sqlite.db"
    # app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    # app.config['SQLALCHEMY_DATABASE_URI'] = "mysql+pymysql://root:root@localhost:3306/test"
    # app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config.from_object(envs.get("develop"))
    init_ext(app)
    init_view(app=app)
    return app
Example #6
0
def create_app():
    app = Flask(__name__)
    # app.register_blueprint(blue)
    # app.register_blueprint(second)
    # # uri  数据库+驱动://用户名:密码@主机:端口/具体哪个库  添加到settings中
    # app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///sqlite.db"
    app.config[
        'SQLALCHEMY_DATABASE_URI'] = "mysql+pymysql://root:@localhost:3306/helloflask"
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    init_ext(app)
    init_view(app=app)

    return app
Example #7
0
def create_app(env):
    app = Flask(__name__)
    # app.register_blueprint(blue)
    # app.register_blueprint(second)

    # uri 数据库+驱动://用户名:密码@主机:端口/具体的库
    # app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///sqlite.db'
    # app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:tian19951103@localhost:3307/GP1HelloFlask'
    # app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True

    app.config.from_object(envs.get(env))

    init_ext(app)
    init_view(app=app)

    return app
Example #8
0
def create_app(env):
    # 初始化Flask、Flask类只有一个必须指定的参数,即程序主模块或者包的名字,让flask.helpers.get_root_path函数通过传入这个名字确定程序的根目录,以便获得静态文件和模板文件的目录
    app = Flask(__name__)

    #初始化视图模块
    init_view(app)

    # app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///test.db"
    # app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

    # 从配置获取当然运行环境配置
    app.config.from_object(envs.get(env))

    # 初始化非视图类第三方模块
    init_ext(app)

    return app
Example #9
0
def creat_app():
    #传项目的路径就是为了找模板的
    app = Flask(__name__,
                template_folder=r"E:\pyCharm\FlaskPro\templates",
                root_path=r'E:\pyCharm\FlaskPro')

    app.config['SQLALCHEMY_DATABASE_URI'] = TestConfing.SQLALCHEMY_DATABASE_URL
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    #app.config.from_object(settings.TestConfing.SQLALCHEMY_DATABASE_URL)
    # app.config.from_object(envs.get("developConfing"))

    # 所有通过懒加载的,在这个入口传对象来注册
    init_view(app)
    init_ext(app)
    #app.register_blueprint(blue)

    return app
Example #10
0
def create_app(env):
    app = Flask(__name__)
    # CORS(app, resources={r"/*": {"origins": "*"}}, supports_credentials=True)
    app.config.update(RESTFUL_JSON=dict(ensure_ascii=False))
    # 初始化项目配置
    app.config.from_object(envs.get(env))
    app.config['SESSION_COOKIE_NAME'] = 'token'
    app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(weeks=9999)
    app.config['SESSION_COOKIE_HTTPONLY'] = True
    app.config['SECRET_KEY'] = os.urandom(24)
    app.config['JSON_SORT_KEYS'] = False
    # 初始化 非路由相关的扩展
    init_ext(app)
    # 初始化api
    init_api(app)
    # 初始化路由
    init_view(app)
    return app
Example #11
0
def create_app(env):
    app = Flask(__name__)

    # app.register_blueprint(blue)
    #
    # app.register_blueprint(second)

    # uri     数据库+驱动://用户名:密码@主机:端口/具体哪一个库
    # app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///sqlite.db"
    # app.config['SQLALCHEMY_DATABASE_URI'] = "mysql+pymysql://root:rock1204@localhost:3306/GP1HelloFlask"
    # app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

    app.config.from_object(envs.get(env))

    init_ext(app)

    init_view(app=app)

    return app
Example #12
0
def create_app(env):
    app = Flask(__name__, static_url_path='/newdbDSM', static_folder='static')
    app.config.from_object(envs.get(env))

    app.config[
        'MAX_CONTENT_LENGTH'] = 5 * 1024 * 1024  # 将网站允许的最大文件设置为5MB,防止拖垮网站
    app.config['UPLOAD_PATH'] = Path(app.root_path).joinpath(
        'files/uploads')  # 设置网站上传文件的路径
    app.config['RESULT_PATH'] = Path(app.root_path).joinpath(
        'files/pred_result')  # 设置预测结果路径
    app.config['DOWNTABLE_PATH'] = Path(app.root_path).joinpath(
        'files/down_table')  # 设置预测结果路径
    Path(app.config['UPLOAD_PATH']).mkdir(exist_ok=True,
                                          parents=True)  # 避免因目录不存在而报错
    Path(app.config['RESULT_PATH']).mkdir(exist_ok=True, parents=True)
    Path(app.config['DOWNTABLE_PATH']).mkdir(exist_ok=True, parents=True)

    init_ext(app=app)
    init_view(app=app)
    return app
Example #13
0
def create_app():
    app = Flask(__name__)
    init_view(app)
    return app
Example #14
0
def create_app():
	app = Flask(__name__)
	# app.register_blueprint(first)
	# app.register_blueprint(second)
	init_view(app=app)
	return app