KoSpades
KoSpades

Reputation: 221

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

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?

Upvotes: 19

Views: 13032

Answers (2)

patkru
patkru

Reputation: 110

According to Uvicorn Documentation, --reload-include does work only if optional dependency Watchfiles (previously called watchgod) is installed.

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

Upvotes: 7

Abhishek Chaudhari
Abhishek Chaudhari

Reputation: 281

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

Upvotes: 23

Related Questions