Code Monkey home page Code Monkey logo

fastapi's Introduction

fastapi

A simple fast api server

Table of Contents

Intoduction

Getting Started

Development Setup

API Walkthrough

Testing

Introduction

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 and price.original should be the same number and discount_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 and discount_percentage represents the applied discount with the % sign

Overview

Getting Started

Installing Dependencies

Python 3.10

Follow instructions to install the latest version of python for your platform in the python docs

Virtual Environment

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

PIP Dependencies

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
Key Dependencies
  • 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.

Initialize and activate a virtualenv using:

python -m virtualenv env
source env/bin/activate

Note - In Windows, the env does not have a bin directory. Therefore, you'd use the analogous command shown below:

source env/Scripts/activate

Install the dependencies:

pip install -r requirements.txt

Dump csv file to postgres database:

python import.py

Run the development server:

uvicorn main:app --reload

Verify on the Browser

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

Testing

pytest

fastapi's People

Contributors

jefedcreator avatar

Watchers

 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.