Skip to content

Instantly share code, notes, and snippets.

[flake8]
exclude =
*migrations*,
__pycache__,
.pytest_cache,
venv,
.env,
.git*,
pytest*,
requirements*,
[MASTER]
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=
# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS
[pytest]
minversion = 6.0
addopts = -ra -q
testpaths =
tests/unit
# -*- 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():
# -*- 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('/index', methods=['GET'])
@app.route('/', methods=['GET'])
def index() -> dict:
"""Handle get requests to /index route.
@app.route('/home', methods=['GET'])
def home() -> str:
"""Provide the user with the option to register with GitHub."""
return render_template('index.html', client_id=app.config['CLIENT_ID']), 200
# -*- coding: utf-8 -*-
"""This module contain the confuguration for the application."""
import os
from dotenv import load_dotenv
load_dotenv()
class BaseConfig():
<!-- templates/index.html -->
<!doctype html>
<html>
<head>
<title>Github OAuth</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> <!-- load bulma css -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <!-- load fontawesome -->
<style>
body { padding-top:70px; }
# -*- coding: utf-8 -*-
"""This module creates the routes for our API."""
from flask import render_template, request
from API import app
from API.helpers import get_access_token, get_user_data
@app.route('/index', methods=['GET'])