Giter Site home page Giter Site logo

hng_boilerplate_python_fastapi_web's Introduction

FASTAPI

FastAPI boilerplate

Setup

  1. Create a virtual environment.
   python3 -m venv .venv
  1. Activate virtual environment.
    source /path/to/venv/bin/activate`
  1. Install project dependencies pip install -r requirements.txt

  2. Create a .env file by copying the .env.sample file cp .env.sample .env

  3. Start server.

python main.py

DATABASE TEST SETUP

To set up the database, follow the following steps:

Cloning

  • clone the repository using git clone https://github.com/hngprojects/hng_boilerplate_python_fastapi_web
  • cd into the directory hng_boilerplate_python_fastapi_web
  • switch branch using git checkout backend

Environment Setup

  • run pip install -r requrements.txt to install dependencies
  • create a .env file in the root directory and copy the content of .env.sample and update it accordingly

Create your local database

sudo -u root psql
CREATE USER user WITH PASSWORD 'your desired password'; 
CREATE DATABASE hng_fast_api;
GRANT ALL PRIVILEGES ON DATABASE hng_fast_api TO user;

Starting the database after cloning the database, dont run alembic revision --autogenerate -m 'initial migration' but run alembic upgrade head

if you make changes to any table locally, then run the below command.

alembic revision --autogenerate -m 'initial migration'
alembic upgrade head

create dummy data

python3 seed.py

Adding tables and columns to models

After creating new tables, or adding new models. Make sure to run alembic revision --autogenerate -m "Migration messge"

TEST THE ENDPOINT

  • run the following code
python -m unittest tests/v1/test_login.py
python -m unittest tests/v1/test_signup.py

hng_boilerplate_python_fastapi_web's People

Contributors

nwanoch avatar armolas avatar waptech07 avatar bolexs avatar agughalamdavis avatar dev-wonderful avatar zxenonx avatar sundaymba avatar abas-dev avatar iamaniekan avatar pythonian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.