Try catch at start
This commit is contained in:
+27
-23
@@ -20,40 +20,44 @@ from flask_jwt_extended import (
|
|||||||
def create_app():
|
def create_app():
|
||||||
"""Factory function to create a Flask app instance"""
|
"""Factory function to create a Flask app instance"""
|
||||||
# import oracledb
|
# import oracledb
|
||||||
|
|
||||||
# oracledb.init_oracle_client(lib_dir=None)
|
# oracledb.init_oracle_client(lib_dir=None)
|
||||||
|
|
||||||
app = Flask(__name__)
|
try:
|
||||||
|
|
||||||
# Load configuration
|
app = Flask(__name__)
|
||||||
app.config.from_object(Config)
|
|
||||||
|
|
||||||
CORS(app)
|
# Load configuration
|
||||||
|
app.config.from_object(Config)
|
||||||
|
|
||||||
JWTManager(app)
|
CORS(app)
|
||||||
CORS(app, supports_credentials=True)
|
|
||||||
|
|
||||||
# Swagger Doc
|
JWTManager(app)
|
||||||
SWAGGER_URL = app.config.get("SWAGGER_URL")
|
CORS(app, supports_credentials=True)
|
||||||
API_URL = app.config.get("API_URL")
|
|
||||||
|
|
||||||
# Register blueprints
|
# Swagger Doc
|
||||||
app.register_blueprint(api)
|
SWAGGER_URL = app.config.get("SWAGGER_URL")
|
||||||
|
API_URL = app.config.get("API_URL")
|
||||||
|
|
||||||
swagger_ui_blueprint = get_swaggerui_blueprint(SWAGGER_URL, API_URL)
|
# Register blueprints
|
||||||
app.register_blueprint(swagger_ui_blueprint, url_prefix=SWAGGER_URL)
|
app.register_blueprint(api)
|
||||||
|
|
||||||
# Error Handlers
|
swagger_ui_blueprint = get_swaggerui_blueprint(SWAGGER_URL, API_URL)
|
||||||
register_error_handlers(app)
|
app.register_blueprint(swagger_ui_blueprint, url_prefix=SWAGGER_URL)
|
||||||
|
|
||||||
from . import models
|
# Error Handlers
|
||||||
|
register_error_handlers(app)
|
||||||
|
|
||||||
# Initialize Flask-Mail
|
from . import models
|
||||||
mail.init_app(app)
|
|
||||||
|
|
||||||
# Database and Migrations
|
# Initialize Flask-Mail
|
||||||
db.init_app(app)
|
mail.init_app(app)
|
||||||
|
|
||||||
migrate.init_app(app, db)
|
# Database and Migrations
|
||||||
|
db.init_app(app)
|
||||||
|
|
||||||
return app
|
migrate.init_app(app, db)
|
||||||
|
|
||||||
|
return app
|
||||||
|
except Exception as e:
|
||||||
|
print(f"An unexpected error occurred: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user