Git Product home page Git Product logo

whid-api's Introduction

whid API

Maintainability Test Coverage action Known Vulnerabilities

This project is a secret API.

Usage

  1. Install Python 3.10 or higher
  2. Install pip if you don't have it
  3. Open a terminal and clone this repo
git clone https://github.com/benrucker/whid-api
  1. cd into the repo
cd whid-api
  1. 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
  1. Install the requirements
python -m pip install -r requirements.txt
  1. Create a file named .env in the root directory of the repo
  2. Add in values for DB_URL and API_TOKENS. For example:
DB_URL="sqlite:///./sql_app.db"
API_TOKENS=["hello"]
  1. Run the app
# dev
uvicorn api.main:app --reload
# production
./run
  1. View the documentation at http://127.0.0.1:8000/docs

Using alembic

When a change has been made to the DB schema, you need to use alembic to update the production database. To do this:

  1. cd to the project folder
  2. git pull or run ./update
  3. Generate a new almebic checkpoint: alembic revision --autogenerate -m "<What was changed>"
  4. 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
  5. If not done already, HUP the running process with ./update

whid-api's People

Contributors

benrucker avatar

Stargazers

 avatar

Watchers

 avatar  avatar

whid-api's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.