Fixed docker start up issue

This commit is contained in:
Azeez Muibi
2025-03-22 17:11:46 +01:00
parent 9deb402322
commit 2baf9a22c1
47 changed files with 194 additions and 86 deletions
+59
View File
@@ -0,0 +1,59 @@
"""
Simbrella FirstAdvance API Flask Implementation
This module serves as the entry point for the Flask application.
"""
from flask import Flask
from flask.typing import ResponseReturnValue
from config import Config
from app.routes import register_blueprints
from app.middleware import register_middleware
import logging
def create_app(config_class=Config) -> Flask:
"""
Factory pattern to create the Flask application.
Args:
config_class: Configuration class to use
Returns:
Flask application instance
"""
app = Flask(__name__)
app.config.from_object(config_class)
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
# Register middleware
register_middleware(app)
# Register blueprints
register_blueprints(app)
# Register error handlers
@app.errorhandler(400)
def bad_request(error) -> ResponseReturnValue:
return {"resultCode": "400", "resultDescription": f"Bad request: {str(error)}"}, 400
@app.errorhandler(404)
def not_found(error) -> ResponseReturnValue:
return {"resultCode": "404", "resultDescription": "Resource not found"}, 404
@app.errorhandler(422)
def validation_error(error) -> ResponseReturnValue:
return {"resultCode": "422", "resultDescription": f"Validation error: {str(error)}"}, 422
@app.errorhandler(500)
def server_error(error) -> ResponseReturnValue:
return {"resultCode": "500", "resultDescription": "Internal server error"}, 500
return app
if __name__ == '__main__':
app = create_app()
port = app.config.get('PORT', 5000)
app.run(debug=app.config.get('DEBUG', False), host='0.0.0.0', port=port)