Skip to content

StaticFilesConfig class

Reference for the StaticFilesConfig class object and how to use it.

Read more about how to use the StaticFilesConfig in your application and leverage the system.

How to import

from esmerald import StaticFilesConfig

esmerald.config.static_files.StaticFilesConfig

Bases: BaseModel

An instance of StaticFilesConfig.

This configuration is used to enable and serve static files via Esmerald application.

Example

from esmerald import Esmerald
from esmerald.config import StaticFilesConfig

static_files_config = StaticFilesConfig(
    path="/static", directory=Path("static")
)

app = Esmerald(static_files_config=static_files_config)

path instance-attribute

path

The path for the statics.

directory class-attribute instance-attribute

directory = None

The directory for the statics in the format of a path like.

Example: /static.

html class-attribute instance-attribute

html = False

Run in HTML mode. Automatically loads index.html for directories if such file exist.

packages class-attribute instance-attribute

packages = None

A list of strings or list of tuples of strings of python packages.

check_dir class-attribute instance-attribute

check_dir = True

Ensure that the directory exists upon instantiation.