This project is a secret API.
- Install Python 3.10 or higher
- Install
pip
if you don't have it - Open a terminal and clone this repo
git clone https://github.com/benrucker/whid-api
cd
into 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
.env
in the root directory of the repo - Add in values for
DB_URL
andAPI_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:
cd
to the project foldergit pull
or 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,
HUP
the running process with./update