build.run   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 29
dl 0
loc 42
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B create_app() 0 27 1
1
from flask import Flask
2
import os
3
from config import app_config
4
from flask_jwt_extended import JWTManager
5
6
config_name = os.getenv('APP_SETTINGS')
7
8
def create_app(config_name):
9
    app = Flask(__name__)
10
    app.config.from_object(app_config[config_name])
11
    #bcrypt = Bcrypt(app)
12
13
14
    #setup flask-jwt-extended extension
15
    app.config['JWT_SECRET_KEY'] = 'secret'
16
    jwt = JWTManager(app)
17
18
    from app import api_bp
19
    app.register_blueprint(api_bp, url_prefix='/api/v1')
20
21
22
    @app.errorhandler(403)
23
    def forbidden(error):
24
        return "Your are not authorized to view this page", 403
25
26
    @app.errorhandler(404)
27
    def page_not_found(error):
28
        return "The resource you are looking for is not available", 404
29
30
    @app.errorhandler(500)
31
    def internal_server_error(error):
32
        return "The server encountered internal error", 500
33
34
    return app
35
36
if __name__=="__main__":
37
    #config_name = os.getenv('APP_SETTINGS')
38
    app = create_app(config_name)
39
    jwt = JWTManager(app)
40
    port = int(os.environ.get('PORT', 5000))
41
    app.run(host='0.0.0.0', port=port)