Coder Social home page Coder Social logo

lodu / fastapi-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 2.0 9 KB

FastAPI boilerplate including an ORM (SQLAlchemy) , data validation (Pydantic), nginx, PostgreSQL and docker-compose!

Dockerfile 4.23% Python 95.77%
fastapi python docker docker-compose pydantic orm sqlalchemy sqlalchemy-python sqlalchemy-orm postresql

fastapi-boilerplate's Introduction

Boilerplate for FastAPI

FastAPI docs Important

  • Passwords are not actually getting hashed.
  • All origins are allowed
  • You might need to set $PYTHONPATH (to parentfolder of src, so where you cloned this repo to)

Docker

Setting up

Postgresql

  • docker volume create postgres-data for persistence of database
  • Create table users and dummydata: see scripts.py for simple function(s)
    • this can be done from either inside (Docker) container or from outside ofcourse.

Optional: Alembic

  • pip install alembic
  • alembic init alembic
  • set URL in alembic.ini (so probably localhost:5432/)
  • for --autogenerate, set target_metadata in alembics env.py like this:
import sys

sys.path = ['', '..'] + sys.path[1:]

from src.database import Base
from src.database.models import User
target_metadata = Base.metadata

Python (without Docker)

Well, thats a lie, we will still use docker for a postgres-database

Tested on Python 3.7+

  • Create virtual env and activate it.

  • pip install -r requirements.txt

  • To run api: uvicorn main:app

    • optionally you can add --reload for watch functionality

docker-compose

Postgres

  • docker volume create postgres-data for persistence of database
  • docker-compose up to run db.

Default config

Change default configs in:

fastapi-boilerplate's People

Contributors

lodu avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

anhpnv mybigman

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.