API for the Tech With Tim website using Quart.
- 🏁 Getting Started
- 🐳 Running with Docker
- ✅ Linting
- 🚨 Tests
- 📚 Docs
- 📜 Licence
- ⛏️ Built Using
- ✍️ Authors
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See Running with Docker if you want to setup the API faster with Docker.
Create a new Discord application here by clicking the New application button and name it whatever you want.
Now that you have an application, go to the OAuth2 tab.
And add http://127.0.0.1:5000/auth/discord/callback to the redirects.
Install Pipenv:
pip install pipenvInstall the required packages and the packages for development with Pipenv:
pipenv install --devSet the environment variables. Start by writing this in a file named local.env:
SECRET_KEY=some_random_characters_here
DB_URI=postgresql://user:password@db:5432/twt
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=And fill in the variables with the values below:
SECRET_KEYis the key used for the JWT token encoding.DB_URIis the PostgreSQL database URI.DISCORD_CLIENT_IDis the Discord application ID. Copy it from your Discord application page (see below).DISCORD_CLIENT_SECRETis the Discord application secret. Copy it from your Discord application page (see below).
Run the API and initialise the database:
pipenv run python launch.py runserver --initdbThe API should run at http://127.0.0.1:5000. For more information about the CLI, check the docs here.
Both the API and the frontend can be started using Docker. Using Docker is generally recommended (but not strictly required) because it abstracts away some additional set up work.
-
Setup the discord app like done here.
-
Make a file named
.envlike done here. You don't need the DB_URI environment variable though. -
Then make sure you have
dockeranddocker-composeinstalled, if not read this for docker and this for docker compose. -
Deploy the API:
docker-compose up
We use a pre-commit hook for linting the code before each commit. Set up the pre-commit hook:
pipenv run pre-commit installIf you want to run the pre-commit checks before trying to commit, you can do it with:
pipenv run lintTo test the API, we use the pytest framework to make sure that the code we write works.
Run the tests:
pipenv run pytestWhen you contribute, you need to add tests on the features you add. An example can be seen in tests/test_index.py.
- Python - Language
- Quart - Backend module
- PostDB - Database module
- pytest-asyncio - Test framework (asynchronous version of pytest)
- @SylteA - Most of the backend
- @Shubhaankar-sharma - Docker deployment
- @takos22 - Some endpoints and markdown files
See also the list of contributors who participated in this project.





