Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 245
KoSpades Avatar asked Nov 20 '25 14:11

KoSpades


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
like image 83
Abhishek Chaudhari Avatar answered Nov 24 '25 00:11

Abhishek Chaudhari


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

like image 20
patkru Avatar answered Nov 24 '25 00:11

patkru



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!