Skip to content

Instantly share code, notes, and snippets.

View twyle's full-sized avatar

lyle okoth twyle

View GitHub Profile
@twyle
twyle / .pre-commit-config.yaml
Created April 29, 2022 08:55
Pre-commit config file.
repos:
- hooks:
- id: trailing-whitespace
- id: check-added-large-files
- id: check-ast
- id: check-docstring-first
- id: debug-statements
language_version: python3
- id: check-executables-have-shebangs
@twyle
twyle / Makefile
Created April 29, 2022 09:45
The Project Makefile
update-pip:
@pip install --upgrade pip
install: update-pip requirements.txt
@pip install -r requirements.txt
install-dev: requirements-dev.txt
@pip install -r requirements-dev.txt
run:
@twyle
twyle / default.json
Created May 1, 2022 08:41
The return from our default route
{
'data': 'Hello from the shield.io json endpoint!'
}
@twyle
twyle / default.json
Created May 1, 2022 08:43
The return from our default route
{
"data": "Hello from the shield.io json endpoint!"
}
@twyle
twyle / badge.json
Created May 1, 2022 08:47
The badge creation data
{
"schemaVersion": 1,
"label": "name",
"message": "your-name",
"color": "color-name",
"labelColor": "color-name",
"style": "style-name"
}
@twyle
twyle / conftest.py
Last active May 13, 2022 07:27
Test config file
# -*- coding: utf-8 -*-
"""This module sets up the fixtures that will be used in our testing."""
import pytest
from API import app
@pytest.fixture
def client():
@twyle
twyle / test_home.py
Last active May 13, 2022 07:27
Testing the home route.
# -*- coding: utf-8 -*-
"""This module tests the home route."""
def test_home(client):
"""Tests that the home route returns ok message on GET request.
GIVEN we have the /api/v1 route
WHEN we send a GET request
THEN we should get a 200 OK response
# -*- coding: utf-8 -*-
"""This module contains initialization code for the API package."""
from dotenv import load_dotenv
from flask import Flask
load_dotenv()
app = Flask(__name__)
# -*- coding: utf-8 -*-
"""This module creates the routes for our API."""
from API import app
@app.route('/api/v1', methods=['GET'])
@app.route('/', methods=['GET'])
def api_home() -> dict:
"""Handle get requests to /api/v1 route.
FLASK_APP=API/__init__.py
FLASK_ENV=development