Passed
Push — master ( 38bed0...e25529 )
by torrua
01:14
created

app.create_app()   A

Complexity

Conditions 1

Size

Total Lines 26
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 26
rs 9.8
c 0
b 0
f 0
cc 1
nop 0
1
from flask import Flask, render_template
2
from flask_bootstrap import Bootstrap
3
4
from app.api.views import blueprints as api_blueprints
5
from app.telegram_bot.routes import bot_routes
6
7
bootstrap = Bootstrap()
8
9
10
def create_app():
11
    """
12
    Create app
13
    """
14
15
    # app initialization
16
    app = Flask(__name__)
17
18
    # bootstrap initialization
19
    bootstrap.init_app(app)
20
    all_blueprints = [*api_blueprints, bot_routes]
21
    # register all blueprints
22
    _ = [
23
        app.register_blueprint(bp.get("blueprint"), url_prefix=bp.get("url_prefix"))
24
        for bp in all_blueprints
25
    ]
26
27
    @app.route("/", methods=["GET"])
28
    @app.route("/index")
29
    def index():
30
        """
31
        example endpoint
32
        """
33
        return render_template("index.html")
34
35
    return app
36