Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Backend

Crud Application

This is to serve as my very first experience using FastAPI, and a reference project for the future.

Documentation

All the documentation of the project can be found in the /docs directory.

Implementation

Prerequisites

  • Python installed
  • MySQL installed and running
  • A MySQL database created and ready

Setup

1. Clone the repository

git clone <your-repo-url>
cd <your-repo-name>

2. Create and activate the virtual environment inside the Project's Folder

# Create
python -m venv .venv

# Activate on Mac/Linux
source .venv/bin/activate

# Activate on Windows
.venv\Scripts\activate

3. Install the required Packages

pip install -r requirements.txt

4. Set up the database

Run the following SQL in your MySQL client:

CREATE DATABASE your_database_name;

USE your_database_name;

CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    familyName VARCHAR(100) NOT NULL,
    age INT NOT NULL
);

5. Configure environment variables

Create a .env file at the root of the project:

DB_HOST=localhost
DB_USER=your_mysql_user
DB_PASSWORD=your_mysql_password
DB_NAME=your_database_name

6. Launch the server

uvicorn app.main:app --reload
  • The API will be available at http://localhost:8000
  • API documentation available at http://localhost:8000/docs

About

This is my very first FastAPI Project, a Backend connected to a MySQL DB that has CRUD Functions for a users Table, this Project's purpose was to learn FastAPI and to have a reference project for the future

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages