Ejemplo n.º 1
0
def create_app():
    app = Flask(__name__,
                template_folder='../templates',
                static_folder='../static')
    app.config.from_object(settings.DeploymentConfigHome)  # 加载settings配置
    app.register_blueprint(user_bp)  # 将蓝图对象user_bp 绑定到app上 print(app.url_map)
    app.register_blueprint(loan_bp)  # 将蓝图对象user_bp 绑定到app上 print(app.url_map)
    db.init_app(app)  # 将db对象与app进行关联
    bootstrap.init_app(app)  # app挂载bootstrap
    # print(app.url_map)  # 打印蓝图
    return app
Ejemplo n.º 2
0
def create_app():
    app = Flask(__name__, template_folder='../templates', static_folder='../static')
    app.config.from_object(Config)  # 配置文件
    db.init_app(app)

    # 注册蓝图
    app.register_blueprint(user_bp)
    app.register_blueprint(alarm_bp)
    app.register_blueprint(device_bp)
    app.register_blueprint(inspect_bp)
    app.register_blueprint(system_bp)
    app.register_blueprint(monitor_bp)
    app.register_blueprint(overview_bp)
    return app
Ejemplo n.º 3
0
def init_configure_extension(app):
    csrf.init_app(app)
    db.init_app(app)
    celery.conf.update(app.config)

    class ContextTask(celery.Task):
        def on_failure(self, exc, task_id, args, kwargs, einfo):
            if isinstance(exc, StandardResponseExc):
                return

            err_str = traceback.format_exc()
            with app.app_context():
                if not current_app.config.get("EXCEPTION_CELERY_ALERT"):
                    return

                task_info_str = "task_name:{}, args:{}, kwargs:{}".format(
                    self.name, args, kwargs)
                err_str = "\n".join([task_info_str, err_str])
                current_app.logger.error(err_str)
            # send_notice_task.delay(err_str.replace("\n", "<br>"))

    celery.Task = ContextTask
Ejemplo n.º 4
0
def create_app(env_config="default"):
    app = Flask(__name__)
    app.config.from_object(config[env_config])
    db.init_app(app)
    urls.init_urls(app)
    return app
Ejemplo n.º 5
0
from flask_bootstrap import Bootstrap
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField
from wtforms.validators import InputRequired, Email, Length
from werkzeug.security import generate_password_hash, check_password_hash
from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user, current_user
from apps.models import User
from apps.ext import db
from apps.tangle import write_data_to_tangle
from apps.findmessages import findmessages
from apps.account import remove
from datetime import datetime, date

app = Flask(__name__)
app.config.from_object('config')
db.init_app(app)
app.config['SECRET_KEY'] = 'eportfoliocredential'
Bootstrap(app)

# flask-login
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'signin'


class SigninForm(FlaskForm):
    student_id = StringField(
        'student_id', validators=[InputRequired(),
                                  Length(min=5, max=15)])
    password = PasswordField(
        'password', validators=[InputRequired(),