2026-01-10 16:49:46 +05:30
|
|
|
from flask import Flask, redirect, url_for
|
2025-12-11 10:16:43 +05:30
|
|
|
from app.config import Config
|
2026-01-10 01:04:21 +05:30
|
|
|
from app.services.db_service import db
|
2025-12-11 10:16:43 +05:30
|
|
|
|
|
|
|
|
def create_app():
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
app.config.from_object(Config)
|
|
|
|
|
|
2026-01-10 13:05:13 +05:30
|
|
|
# Initialize extensions
|
2025-12-11 10:16:43 +05:30
|
|
|
db.init_app(app)
|
|
|
|
|
|
2026-01-10 13:05:13 +05:30
|
|
|
# Register blueprints
|
|
|
|
|
register_blueprints(app)
|
|
|
|
|
# Register error handlers
|
|
|
|
|
register_error_handlers(app)
|
|
|
|
|
|
2026-01-10 16:49:46 +05:30
|
|
|
# ROOT → LOGIN
|
|
|
|
|
@app.route("/")
|
|
|
|
|
def index():
|
|
|
|
|
return redirect(url_for("auth.login"))
|
|
|
|
|
|
2026-01-10 13:05:13 +05:30
|
|
|
return app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def register_blueprints(app):
|
2026-01-10 01:04:21 +05:30
|
|
|
from app.routes.auth import auth_bp
|
|
|
|
|
from app.routes.user import user_bp
|
2025-12-11 10:16:43 +05:30
|
|
|
from app.routes.dashboard import dashboard_bp
|
2026-01-10 01:04:21 +05:30
|
|
|
from app.routes.subcontractor_routes import subcontractor_bp
|
2025-12-11 10:16:43 +05:30
|
|
|
from app.routes.file_import import file_import_bp
|
2025-12-12 11:38:54 +05:30
|
|
|
from app.routes.file_report import file_report_bp
|
2025-12-13 18:50:27 +05:30
|
|
|
from app.routes.generate_comparison_report import generate_report_bp
|
2026-01-10 13:05:13 +05:30
|
|
|
from app.routes.file_format import file_format_bp
|
2025-12-23 15:02:04 +05:30
|
|
|
|
2026-01-10 01:04:21 +05:30
|
|
|
app.register_blueprint(auth_bp)
|
|
|
|
|
app.register_blueprint(user_bp)
|
2025-12-11 10:16:43 +05:30
|
|
|
app.register_blueprint(dashboard_bp)
|
2026-01-10 01:04:21 +05:30
|
|
|
app.register_blueprint(subcontractor_bp)
|
2025-12-11 10:16:43 +05:30
|
|
|
app.register_blueprint(file_import_bp)
|
2025-12-12 11:38:54 +05:30
|
|
|
app.register_blueprint(file_report_bp)
|
2025-12-13 18:50:27 +05:30
|
|
|
app.register_blueprint(generate_report_bp)
|
2026-01-10 13:05:13 +05:30
|
|
|
app.register_blueprint(file_format_bp )
|
2025-12-11 10:16:43 +05:30
|
|
|
|
2026-01-10 13:05:13 +05:30
|
|
|
|
|
|
|
|
def register_error_handlers(app):
|
|
|
|
|
@app.errorhandler(404)
|
|
|
|
|
def page_not_found(e):
|
|
|
|
|
return "Page Not Found", 404
|
|
|
|
|
|
|
|
|
|
@app.errorhandler(500)
|
|
|
|
|
def internal_error(e):
|
|
|
|
|
return "Internal Server Error", 500
|