Skip to content

Allow template_folder to be a pathlib.Path object #4892

@legoktm

Description

@legoktm

When constructing the Flask object, it would be nice if template_folder could be either a string (currently) or a pathlib.Path object. This would match static_folder, which is currently typed as Union[str, os.PathLike]. That functionality was added in #3579; I was unable to find any reason why the same wasn't done for template_folder, so I assume it was an unintentional omission.

https://flask.palletsprojects.com/en/2.2.x/api/#application-object

Not having this functionality is not a dealbreaker, as it's pretty simple to do template_folder=str(path), but it would be nice and match static_folder. In SecureDrop our code is going to look like:

    app = Flask(
        __name__,
        template_folder=str(config.JOURNALIST_TEMPLATES_DIR.absolute()),
        static_folder=config.STATIC_DIR,
    )

...so implementing this would be nice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions