Asynchronous API for workout tracker application. Created with FastAPI and PostgreSQL database.
Clone repo.
Use the package manager pip to install all dependencies from requirements file.
pip install -r requirements.txt
Before running the server, .env
file with input variables needs to be created in project root directory, like so:
VAR1_NAME=VAR1_VALUE
VAR2_NAME=VAR2_VALUE
...
Variables list:
DATABASE_URL
: URL of PostgreSQL database. Syntax:
postgresql://username:password:@server_address/database_name
SECRET_KEY
: 256-bit unique hex key used for password encryption.SUPERUSER
: Superuser login.SUPERUSER_PASSWORD
: Superuser password.
Include this only if running server by executing main.py
:
SERVER_HOST
: Server address. Use0.0.0.0
to make application available on local network.SERVER_PORT
: Server port number, e.g.8000
Either run main.py
, or run the following command from root directory:
uvicorn app.main:app
To make the server reload after making changes, add the parameter:
uvicorn app.main:app --reload
After running the server, API documentation is available under:
http(s)://SERVER_HOST:SERVER:PORT/docs
After any changes or additions in database models, new alembic revision has to be created using the following command:
alembic revision --autogenerate -m "example message"
And then to upgrade the database to the newest revision:
alembic upgrade head