A simple fast api server
This is a simple fast api server with two apis. a home api that returns hello world and a get products api that Can be filtered by category
as a query parameter and Can be filtered by price_less_than
as a query parameter, returns products that meet these criteria.- Returns a list of products with the given discounts applied where necessary.
- When a product does not have a discount,
price.final
andprice.original
should be the same number anddiscount_percentage
should be null. - When a product has a discount
price.original
is the original price,price.final
is the amount with the discount applied anddiscount_percentage
represents the applied discount with the % sign
Follow instructions to install the latest version of python for your platform in the python docs
We recommend working within a virtual environment whenever using Python for projects. This keeps your dependencies for each project separate and organized. Instructions for setting up a virtual environment for your platform can be found in the python docs
Once you have your virtual environment setup and running, install dependencies by navigating to the /fast_api
directory and running:
pip install -r requirements.txt
-
Fast Api FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
-
SQLAlchemy python libraries to handle the postgresql database.
python -m virtualenv env
source env/bin/activate
Note - In Windows, the
env
does not have abin
directory. Therefore, you'd use the analogous command shown below:
source env/Scripts/activate
pip install -r requirements.txt
python import.py
uvicorn main:app --reload
Navigate to project homepage http://127.0.0.1:8000/ or http://localhost:8000
or swagger docs Navigate to project homepage http://127.0.0.1:8000/docs
pytest