Passed
Push — master ( 685969...5bf913 )
by torrua
02:02
created

app.main   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 25
dl 0
loc 45
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A create_app() 0 33 1
1
from flask import Flask, render_template
2
3
from flask_bootstrap import Bootstrap
4
5
from app.api.views import blueprints as api_blueprints
6
from app.bot import bot_blueprint
7
from app.site import site_blueprint
8
9
bootstrap = Bootstrap()
10
11
12
def create_app():
13
    """
14
    Create app
15
    """
16
17
    # app initialization
18
    app = Flask(__name__)
19
20
    # bootstrap initialization
21
    bootstrap.init_app(app)
22
    # register all blueprints
23
    app.register_blueprint(bot_blueprint, url_prefix="/bot")
24
    app.register_blueprint(site_blueprint, url_prefix="/site")
25
26
    _ = [
27
        app.register_blueprint(bp.get("blueprint"), url_prefix=bp.get("url_prefix"))
28
        for bp in api_blueprints
29
    ]
30
    app.debug = True
31
32
    @app.errorhandler(404)
33
    def page_not_found(_):
34
        return render_template("404.html"), 404
35
36
    @app.route("/", methods=["GET"])
37
    @app.route("/index")
38
    def index():
39
        """
40
        example endpoint
41
        """
42
        return render_template("index.html")
43
44
    return app
45