A sample FastAPI project implemented using the MVC Pattern.
- [βοΈ] MIT License
- [βοΈ] FastApi + SQLAlchemy
- [βοΈ] Class Based Controller with fastapi-router-controller
- [βοΈ] Tests with unittest
- [βοΈ] Dockerfile with tiangolo/uvicorn-gunicorn-fastapi:python3.8
- [βοΈ] Configuration management with Environment Variables Interpolation
- [βοΈ] Centralized logging management
- [βοΈ] Log requests end-time
- [βοΈ] Formatted Exception Handler
- [βοΈ] Validation Exception Handler
- [βοΈ] Vscode dotfiles preconfigured
- [βοΈ] GitHub action for unit tests on PR
- [βοΈ] Sample Gunicorn Configuration
- Clone this repository or download it. Customize!
- Just click on 'Use this template' button on GitHub page
First install the dependencies
pip install -r requirements.txt
I included in the repository the VSCode configuration for tasks and debugging.
So, you can just use the VSCode shortcut to start the application:
- Start FastApi
- Start FastApi with Gunicorn
There are also two debug configurations:
- Debug FastApi
- Debug Python Current File
See more about VScode Tasks and Debug.
- Start with unicorn
pip install unicorn
uvicorn server/main:app --reload
- Start with gunicorn
pip install gunicorn
gunicorn server/main:app --config gunicorn_conf.py
Install tests requirements
pip install -r tests/requirements.txt
Run
python3 -m unittest discover -s tests -p '*_test.py'
I am open to suggestions and criticisms, please, if something seems wrong or can be improved, tell it through an issue on the project