Last active
June 2, 2022 09:56
-
-
Save twyle/81021e89433451d2e43faa2607131de0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""This module contains initialization code for the api package.""" | |
from flask import Flask, redirect, url_for | |
from api.helpers import set_flask_environment | |
from .blueprints.default.views import default | |
from .blueprints.auth.views import auth | |
from flask_dance.contrib.github import github | |
app = Flask(__name__) | |
set_flask_environment(app=app) | |
app.register_blueprint(default) | |
app.register_blueprint(auth, url_prefix='/login') | |
@app.route('/github') | |
def login(): | |
"""Log in a registered or authenticated user.""" | |
if not github.authorized: | |
return redirect(url_for('github.login')) | |
res = github.get('/user') | |
return f"You are logged in as {res.json()['login']} on GitHub." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment