Skip to content

A template repository for a FastAPI back-end. It is secured with OAuth 2.0 and uses JWT tokens for authentication and authorization. Uses MySQL for database management.

License

dilshankarunarathne/secure-fastapi-template

Repository files navigation

FastAPI Project Template

The REST API template repository for a FastAPI back-end project.

Version License

Table of Contents

Description

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.

Installation

Prerequisites

  • Python 3.8 or higher
  • pip 20.0 or higher
  • fastapi
  • uvicorn
  • pydantic
  • jose
  • passlib
  • mysql

Installation Steps

  1. Clone the repository
git clone https://github.com/dilshankarunarathne/secure-fastapi-template.git
  1. Install the dependencies
pip install -r requirements.txt
  1. Create a MySQL database
mysql -u root -p
CREATE DATABASE fastapi;
  1. 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
  1. Run the project
uvicorn main:app --reload
  1. Open the local URL in a browser to access the Swagger UI
http://127.0.0.1:8000/auth/login

Contributing

If you'd like to contribute to this project, please check the contribution guidelines for more information.

License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. CC BY-NC-SA 4.0
CC BY-NC-SA 4.0

Contact Information

For questions or feedback, please contact the author:

About

A template repository for a FastAPI back-end. It is secured with OAuth 2.0 and uses JWT tokens for authentication and authorization. Uses MySQL for database management.

Topics

Resources

License

Stars

Watchers

Forks

Languages