| Conditions | 1 |
| Total Lines | 25 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | from flask import Flask |
||
| 8 | def create_app(config_filename): |
||
| 9 | app = Flask(__name__) |
||
| 10 | app.config.from_object(app_config[config_filename]) |
||
| 11 | |||
| 12 | #setup flask-jwt-extended extension |
||
| 13 | app.config['JWT_SECRET_KEY'] = 'secret' |
||
| 14 | jwt = JWTManager(app) |
||
| 15 | |||
| 16 | from app import api_bp |
||
| 17 | app.register_blueprint(api_bp, url_prefix='/api/v1') |
||
| 18 | |||
| 19 | |||
| 20 | @app.errorhandler(403) |
||
| 21 | def forbidden(error): |
||
| 22 | return "Your are not authorized to view this page", 403 |
||
| 23 | |||
| 24 | @app.errorhandler(404) |
||
| 25 | def page_not_found(error): |
||
| 26 | return "The resource you are looking for is not available", 404 |
||
| 27 | |||
| 28 | @app.errorhandler(500) |
||
| 29 | def internal_server_error(error): |
||
| 30 | return "The server encountered internal eror", 500 |
||
| 31 | |||
| 32 | return app |
||
| 33 | |||
| 38 | app.run(host='0.0.0.0', port=port) |