The REST API template repository for a FastAPI back-end project.
This is a template repository for a FastAPI back-end project. It is intended to be used as a starting point for a new project. It has OAuth2 authentication and JWT token generation. It also has a basic user model and CRUD operations for users.
- Python 3.8 or higher
- pip 20.0 or higher
- fastapi
- uvicorn
- pydantic
- jose
- passlib
- mysql
- Clone the repository
git clone https://github.com/dilshankarunarathne/secure-fastapi-template.git
- Install the dependencies
pip install -r requirements.txt
- Create a MySQL database
mysql -u root -p
CREATE DATABASE fastapi;
- Create a
.env
file in the root directory and add the following environment variables
MYSQL_USER="your mysql user"
MYSQL_PASSWORD="your mysql password"
MYSQL_HOST="localhost"
MYSQL_DATABASE="fastapi"
MYSQL_PORT=3306
- Run the project
uvicorn main:app --reload
- Open the local URL in a browser to access the Swagger UI
http://127.0.0.1:8000/auth/login
If you'd like to contribute to this project, please check the contribution guidelines for more information.
This work is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
For questions or feedback, please contact the author:
- Author: Dilshan M. Karunarathne
- Email: [email protected]
- Website: http://altier.tech