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 volume create postgres-datafor persistence of database- Create table
usersand dummydata: see scripts.py for simple function(s)- this can be done from either inside (Docker) container or from outside ofcourse.
pip install alembicalembic init alembic- set URL in alembic.ini (so probably
localhost:5432/) - for
--autogenerate, settarget_metadatain alembicsenv.pylike this:
import sys
sys.path = ['', '..'] + sys.path[1:]
from src.database import Base
from src.database.models import User
target_metadata = Base.metadata
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
--reloadfor watch functionality
- optionally you can add
- Make comment of/Remove the services of
apiandproxyin docker-compose.yaml
docker volume create postgres-datafor persistence of databasedocker-compose upto run db.
Change default configs in: