import pydantic
from flask import Flask
from flask_cors import CORS
from flask_pydantic import validate
from starlette.responses import JSONResponse

from app.config import Constants
from app.schemas import CommonResponseSchema
from app.utils.logger import logger
from app.controllers.sample_controller import sample_router


def create_flask_app() -> Flask:
    base_app = Flask(__name__)
    CORS(base_app)
    return base_app



{{app_name}}: Flask = create_flask_app()



@{{app_name}}.route(f"{Constants.BASE_SLUG}/public/ping", methods=["GET"])
@validate()
def ping():
    function_name = "Ping - Health Check"
    logger.info(
        message=f"Enter - {function_name}",
        function_name=function_name,
    )
    return JSONResponse(
        content=CommonResponseSchema(
            message="Health check ping working for public", status="Ok"
        ).dict(),
        status_code=200,
    )


{{app_name}}.register_blueprint(sample_router)