How to reload FastAPI app when a file, other than *.py files, changes?

Viewed 725

I want my FastAPI app to reload when a .csv file in the same directory changes.

I tried the following command, but it isn't working.

uvicorn main:app --reload --reload-include *.csv

Does anyone know a solution to this problem?

2 Answers

As per Uvicorn documentation, you can install watchfiles, and use --reload-include, as well as --reload-exclude, to specify other file extensions. For example:

uvicorn main:app --reload --reload-include *.csv

According to Uvicorn Documentation, --reload-include does work only if optional dependency Watchgod is installed.

Try installing it with pip install watchgod and then run uvicorn again

Related