Configuring FastAPI
If you can run the fastapi dev command locally, you should be able to deploy to FastAPI Cloud with fastapi deploy as well! ✨
Custom Entrypoint - Location
Section titled “Custom Entrypoint - Location”If you normally need to pass a path file to the fastapi dev command, for example like:
fastapi dev my_app/main.py…you can instead configure it in the pyproject.toml file.
You can do this by adding a [tool.fastapi] section in the pyproject.toml file, for example:
[tool.fastapi]entrypoint = "my_app.main:app"This configuration tells the fastapi command to import the app object from the my_app.main “module” (the file my_app/main.py) as the FastAPI application instance.
It’s equivalent to:
from my_app.main import appAfter this configuration, you should be able to just run:
fastapi devIf now it works without passing the path, then you can now deploy with just:
fastapi deployAnd that should work as well! 🚀