This project is a secret API.
- Install Python 3.10 or higher
- Install
pipif you don't have it - Open a terminal and clone this repo
git clone https://github.com/benrucker/whid-apicdinto the repo
cd whid-api- Create and activate a virtual environment
# Windows:
python -m pip install venv
python -m venv .venv
.\\.venv\\Scripts\\activate# Mac and Linux:
python3 -m pip install venv
python3 -m venv .venv
. .venv/bin/activate- Install the requirements
python -m pip install -r requirements.txt- Create a file named
.envin the root directory of the repo - Add in values for
DB_URLandAPI_TOKENS. For example:
DB_URL="sqlite:///./sql_app.db"
API_TOKENS=["hello"]
- Run the app
# dev
uvicorn api.main:app --reload# production
./run- View the documentation at http://127.0.0.1:8000/docs
When a change has been made to the DB schema, you need to use alembic to update the production database. To do this:
cdto the project foldergit pullor run./update- Generate a new almebic checkpoint:
alembic revision --autogenerate -m "<What was changed>" - Update the db:
alembic upgrade head- If you get an error with null values, update the revision script like this:
# old: op.add_column('channel', sa.Column('type', sa.String(), nullable=True))
# fixed: op.add_column('channel', sa.Column('type', sa.String())) op.execute('update channel set type = \'text\'') op.alter_column('channel', 'type', nullable=False)
- Rerun the update command
- If not done already,
HUPthe running process with./update