Skip to content

elman23/postapp

Repository files navigation

Post App

A FastAPI project.

Virtual environments

Create a virtual environment and activate it:

  • Windows:
py -3 -m venv venv
.\venv\Scripts\activate.bat
  • Unix:
python3 -m venv venv
source ./venv/bin/activate

Dependencies

pip install "fastapi[all]" 
pip freeze > requirements.txt

Run

uvicorn app.main:app --reload

Documentation

Swagger built-in at: http://localhost:8000/docs.

ReDoc built-in at: http://localhost:8000/redoc.

Alembic

alembic init alembic

Configure alembic/env.py.

alembic revision -m "create post table"

Fill in the upgrade() and downgrade() functions.

Apply the revision:

alembic current
alembic upgrade [REVISION_NUMBER]

Other commands:

alembic heads
alembic upgrade head 

Downgrade:

alembic downgrade [REVISION_NUMBER]
alembic downgrade -1

Automatically generate features:

alembic revision --autogenerate -m "[MESSAGE HERE]"

Tests

Run tests with:

pytest

More verbose:

pytest -v

Print:

pytest -v -s

Disable warnings:

pytest --disable-warnings

Stop after first test failure:

pytest -x

Links

Tutorial: from freeCodeCamp.

About

REST API for Post application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published