__init__.py 1.87 KB
Newer Older
Weizhi Cui's avatar
Weizhi Cui committed
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
# @Version     : Python 3.11.4
# @Software    : Sublime Text 4
# @Author      : StudentCWZ
# @Email       : StudentCWZ@outlook.com
# @Date        : 2023/10/28 12:50
# @File        : __init__.py
# @Description :
"""


崔为之's avatar
崔为之 committed
14
from flask import Flask
崔为之's avatar
崔为之 committed
15

崔为之's avatar
崔为之 committed
16
# Import the initialization functions in alphabetical order
崔为之's avatar
崔为之 committed
17 18
from .init_apispec import init_apispec
from .init_apscheduler import init_tasks
Weizhi Cui's avatar
Weizhi Cui committed
19
from .init_config import init_config
崔为之's avatar
崔为之 committed
20
from .init_consul import init_consul
崔为之's avatar
崔为之 committed
21
from .init_cors import init_cors
崔为之's avatar
崔为之 committed
22
from .init_dotenv import init_dotenv
崔为之's avatar
崔为之 committed
23
from .init_elasticsearch import init_elasticsearch
Weizhi Cui's avatar
Weizhi Cui committed
24 25 26 27
from .init_logger import init_logger
from .init_sqlalchemy import init_database

def init_plugs(app: Flask) -> None:
崔为之's avatar
崔为之 committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41
    """
    This function initializes various plugins for a Flask application.

    It accepts a Flask application instance as an argument, and calls a series of initialization
    functions on this instance, setting up several plugins.

    Each plugin is initialized by a function imported from a separate module. These initialization
    functions should take the Flask application instance as an argument, and set up the plugin for
    this instance.

    Note that the order in which these plugins are initialized can be important, as some plugins may
    depend on others being already initialized.
    """
    # Initialize the environment variables
崔为之's avatar
崔为之 committed
42
    init_dotenv()
崔为之's avatar
崔为之 committed
43 44

    # Initialize the application configuration
Weizhi Cui's avatar
Weizhi Cui committed
45
    init_config(app)
崔为之's avatar
崔为之 committed
46 47

    # Initialize the application logging
Weizhi Cui's avatar
Weizhi Cui committed
48
    init_logger(app)
崔为之's avatar
崔为之 committed
49 50

    # Initialize the database connection
Weizhi Cui's avatar
Weizhi Cui committed
51
    init_database(app)
崔为之's avatar
崔为之 committed
52 53

    # Initialize the API specification
Weizhi Cui's avatar
Weizhi Cui committed
54
    init_apispec(app)
崔为之's avatar
崔为之 committed
55 56

    # Initialize the Elasticsearch client
崔为之's avatar
崔为之 committed
57
    init_elasticsearch(app)
崔为之's avatar
崔为之 committed
58 59

    # Initialize the CORS policy
崔为之's avatar
崔为之 committed
60
    init_cors(app)
崔为之's avatar
崔为之 committed
61 62

    # Initialize the Consul client
崔为之's avatar
崔为之 committed
63
    init_consul(app)
崔为之's avatar
崔为之 committed
64 65

    # Initialize the scheduled tasks
崔为之's avatar
崔为之 committed
66
    init_tasks(app)