https://github.com/genesisblock3301/product_delivery_fastapi
Product delivery api
https://github.com/genesisblock3301/product_delivery_fastapi
fastapi python
Last synced: about 2 months ago
JSON representation
Product delivery api
- Host: GitHub
- URL: https://github.com/genesisblock3301/product_delivery_fastapi
- Owner: GenesisBlock3301
- Created: 2021-12-27T05:04:52.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-27T05:21:45.000Z (over 4 years ago)
- Last Synced: 2025-01-08T18:46:10.700Z (over 1 year ago)
- Topics: fastapi, python
- Language: Python
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Product Delivery FastAPI
## What is fastAPI ?
FastAPI is a Web framework for developing RESTful APIs in Python. FastAPI is based on Pydantic and type hints to validate, serialize, and deserialize data, and automatically auto-generate OpenAPI documents. It fully supports asynchronous programming and can run with Uvicorn and Gunicorn.
### Install FastAPI
```
pip install "fastapi[all]"
```
You can also install it part by part.
This is what you would probably do once you want to deploy your application to production:
```
pip install fastapi
```
Also install uvicorn to work as the server:
```
pip install "uvicorn[standard]"
```
## what is uvicorn ?
Uvicorn is a lightning-fast ASGI server implementation, using uvloop and httptools.
## What is pydentic model
You can think of models as similar to types in strictly typed languages, or as the requirements of a single endpoint in an API.
## Database connection
```
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db"
# SQLALCHEMY_DATABASE_URL = "postgresql://user:password@postgresserver/db"
engine = create_engine(
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
```
## Run server
```
uvicorn main:app --reload
```
# Project structure
## models:
All database related files
## schemas:
All pydentic model files
## routers
All end point define here