XinYi Song
c5481ead05
2、整合JPSS,葵花8,GF3,哨兵1,哨兵2,哨兵3,资源2号,环境1号,SNPP等遥感数据解析算法。 3、flask中添加扫描各个卫星扫描任务,定时扫描,数据入库
53 lines
1.1 KiB
Python
53 lines
1.1 KiB
Python
# 项目初始化文件
|
|
import logging
|
|
from logging.handlers import RotatingFileHandler
|
|
from flask import Flask
|
|
from redis import StrictRedis
|
|
from flask_wtf.csrf import CSRFProtect
|
|
from flask_session import Session
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
|
|
from application.settings.dev import DevelopmentConfig
|
|
from application.settings.prop import ProductionConfig
|
|
from common.config.factory import create_app
|
|
|
|
config = {
|
|
'dev': DevelopmentConfig,
|
|
'prop': ProductionConfig,
|
|
|
|
}
|
|
|
|
|
|
def init_app(config_name):
|
|
"""
|
|
项目初始化
|
|
:param config_name:
|
|
:return:
|
|
"""
|
|
# 主应用的根目录
|
|
app = Flask(__name__)
|
|
|
|
# 设置配置类
|
|
Config = config[config_name]
|
|
|
|
# 加载配置
|
|
app.config.from_object(Config)
|
|
|
|
# redis的连接初始化
|
|
# global redis_store
|
|
# redis_store = StrictRedis(host=Config.CACHE_REDIS_HOST, port=Config.CACHE_REDIS_PORT, db=0)
|
|
|
|
# 开启CSRF防范
|
|
CSRFProtect(app)
|
|
|
|
# 开启session
|
|
Session(app)
|
|
|
|
# 增加数据库连接
|
|
# db.init_app(app)
|
|
#
|
|
# # 启用日志
|
|
# setup_log(Config)
|
|
|
|
return app
|