Giter Site home page Giter Site logo

zbce-mockup's Introduction

ZBCE FastAPI REST API Mockup

A REALLY basic AND quickly written REST API to illustrate the basic features of FastAPI. Only weight endpoints are implemented.

Basic Features

  • Modularizable file structure
  • Automatically generating documentation
  • It's fast
  • Input verification through Pydantic schemas
  • It's better than Flask

File Structure

  • app/routers : Handle HTTP requests and route them to proper controller
  • app/controllers : take request object, pull out data from request, validate, then send to service(s)
  • app/models : Classes and instances that interact with database
  • app/schemas : Schemas for API requests/responses
  • app/services : Contains business logic as well as well as access to database
  • app/config.py : reads enviromental variables from .env file
  • .env : (Not here because you need to add it yourself) Contains all the secret keys and other stuff
  • app/main.py : Connects everything together

Installation

Create Python 3 virtual environment

python3 -m venv env

Activate virtual enviroment

On Windows,

env/Scripts/activate.bat

On Linux or MacOS,

source env/bin/activate

Install required libraries

pip install -r requirements.txt

Create .env file

Create .env file with the contents. Fill it the key with your appropriate username and password.

SQLALCHEMY_DATABASE_URL="mysql+pymysql://USERNAME:PASSWORD@localhost/zotbinsCE"

Starting the FastAPI server

After completing all the steps, run the command

uvicorn app.main:app --reload

Make sure you activated your virtual environment before running the command else the command wil fail

If the server succesfully started, you are all done!

You can look at the automatically generated docs at http://127.0.0.1:8000/

zbce-mockup's People

Contributors

patrickanguyen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.