Example #1
0
File: app.py Project: jerkos/kepavi
def create_app(config=None):
    """Creates the app."""
    # Initialize the app
    app = Flask("Kepavi")

    # Use the default config and override it afterwards
    app.config.from_object('kepavi.configs.default.DefaultConfig')
    # Update the config
    app.config.from_object(config)
    # try to update the config via the environment variable
    app.config.from_envvar("FLASKBB_SETTINGS", silent=True)

    # github extensions, TODO put that into configs directory
    app.config['GITHUB_CLIENT_ID'] = 'ed057c9e07f531f0fdb6'
    app.config['GITHUB_CLIENT_SECRET'] = os.environ.get('GITHUB_CLIENT_SECRET') or GITHUB_CLIENT_SECRET

    app.config['MONGODB_SETTINGS'] = {'db': 'biomodels', 'host': 'mongodb://localhost:27017/biomodels'}

    configure_blueprints(app)

    configure_extensions(app)

    configure_template_filters(app)

    # configure_context_processors(app)

    #configure_before_handlers(app)

    configure_errorhandlers(app)

    #configure_logging(app)

    app.logger.addHandler(logging.StreamHandler(sys.stdout))
    app.logger.setLevel(logging.INFO)
    return app
Example #2
0
def create_app(config=None):
    """
    Creates the app.
    """
    # Initialize the app
    app = Flask("flaskbb")

    # Use the default config and override it afterwards
    app.config.from_object('metabomatch.configs.default.DefaultConfig')
    # Update the config
    app.config.from_object(config)
    # try to update the config via the environment variable
    app.config.from_envvar("FLASKBB_SETTINGS", silent=True)

    #github extensions, TODO put that into configs directory
    app.config['GITHUB_CLIENT_ID'] = 'ed057c9e07f531f0fdb6'
    app.config['GITHUB_CLIENT_SECRET'] = os.environ.get('GITHUB_CLIENT_SECRET') or GITHUB_CLIENT_SECRET
    configure_blueprints(app)
    configure_extensions(app)
    configure_template_filters(app)
    configure_context_processors(app)
    configure_before_handlers(app)
    configure_errorhandlers(app)
    #configure_logging(app)

    app.logger.addHandler(logging.StreamHandler(sys.stdout))
    app.logger.setLevel(logging.ERROR)
    # app.debug = True
    return app
Example #3
0
def create_app(environ):
    app = Flask(__name__, static_url_path='/brigade/static')
    app.secret_key = "sangria wreath"
    app.config['BRIGADE_SIGNUP_SECRET'] = environ['BRIGADE_SIGNUP_SECRET']
    app.config['GITHUB_CLIENT_ID'] = environ['GITHUB_CLIENT_ID']
    app.config['GITHUB_CLIENT_SECRET'] = environ['GITHUB_CLIENT_SECRET']

    # github.app = app
    github.init_app(app)

    app.register_blueprint(brigade)
    app.register_blueprint(filters)
    return app
    def test_authorization(self, auth_url, post):
        def assert_params(*args, **kwargs):
            data = kwargs.pop('data')
            assert data['client_id'] == '123'
            assert data['client_secret'] == 'SEKRET'
            assert data['code'] == 'KODE'
            response = Mock()
            response.content = b'access_token=asdf&token_type=bearer'
            return response
        post.side_effect = assert_params
        auth_url.__get__ = Mock(return_value='http://localhost/oauth/')

        app = Flask(__name__)

        app.config['GITHUB_CLIENT_ID'] = '123'
        app.config['GITHUB_CLIENT_SECRET'] = 'SEKRET'

        github = GitHub(app)

        @app.route('/login')
        def login():
            return github.authorize(redirect_uri="http://localhost/callback")

        @app.route('/callback')
        @github.authorized_handler
        def authorized(token):
            access_token.append(token)
            return ''

        # Mimics GitHub authorization URL
        # http://developer.github.com/v3/oauth/#web-application-flow
        @app.route('/oauth/authorize')
        def handle_auth():
            logger.info("in /oauth/authorize")
            called_auth.append(1)
            assert request.args['client_id'] == '123'
            logger.debug("client_id OK")
            assert request.args['redirect_uri'] == 'http://localhost/callback'
            logger.debug("redirect_uri OK")
            return redirect(request.args['redirect_uri'] + '?code=KODE')

        access_token = []
        called_auth = []

        client = app.test_client()
        client.get('/login', follow_redirects=True)

        assert called_auth
        assert access_token == ['asdf'], access_token
def create_app():
    """ Creates the app and initializes the components """
    app = Flask(__name__)

    app.config['SECRET_KEY'] = 'voll geheim!'
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///catalog.sqlite'

    app.config['GITHUB_CLIENT_ID'] = 'd73ccb593f271410d8a6'
    app.config['GITHUB_CLIENT_SECRET'] = 'b33db87574d91ec86296a1a52871e1ec66c1f69b'

    bootstrap.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    github.init_app(app)

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix='/auth')

    return app
Example #6
0
# inspired by https://github.com/cenkalti/github-flask/blob/master/example.py
# setup flask
from flask import Flask, render_template, request, redirect, url_for, jsonify, flash, g, session
from flask.ext.seasurf import SeaSurf
app = Flask(__name__)
csrf = SeaSurf(app)
# setup ssl if needed
"""import ssl
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.load_cert_chain('/etc/ssl/private/server.pem')"""

# setup client id and secret of github application for oauth 
from flask.ext.github import GitHub

# config application
app.config['GITHUB_CLIENT_ID'] = 'eeb4dfb78a394e99200c'
app.config['GITHUB_CLIENT_SECRET'] = 'e4a94257eaf8a0724670bd861340e12ff51d92ad'
app_secret = 'gh_app_secret'
github_callback_url = "http://localhost:5000/github-callback"
github = GitHub(app)

# setup sqlalchemy
from sqlalchemy import create_engine, desc
from sqlalchemy.orm import sessionmaker,scoped_session
from database_setup import Base, Category, Item, User
engine = create_engine('sqlite:///catalog.db')

Base.metadata.bind = engine

# http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html#sqlalchemy.orm.scoping.scoped_session
db_session = scoped_session(sessionmaker(autocommit=False,
Example #7
0
from flask import Flask, jsonify, render_template, redirect, make_response
from flask.ext.github import GitHub

app = Flask(__name__)
app.debug = True
app.config['GITHUB_CLIENT_ID'] = 'b8047c4fddfe18ac9cdf'
app.config['GITHUB_CLIENT_SECRET'] = 'ac45bd47f2cb9e7f04f1106c7ae35ec0229a6d3b'
app.config['GITHUB_CALLBACK_URL'] = 'http://127.0.0.1:5000/gcb'
app.config['REPO_NAME'] = 'Hipmunk'
app.config['REPO_OWNER'] = 'Hipmunk'
github = GitHub(app)

@app.route("/")
def main():
    return render_template("main.html")


@app.route("/login")
def login():
    return github.authorize(scope="repo")


@app.route("/gcb")
@github.authorized_handler
def gcb(oauth_token):
    if oauth_token is None:
        return redirect("/")

    resp = make_response(render_template("main.html"))
    resp.set_cookie("user_auth_token", oauth_token)
    resp.set_cookie("user_repo", app.config['REPO_NAME'])
Example #8
0
from random import random
from flask import Flask, render_template, request, url_for, redirect, flash, jsonify, g, session, abort
from sqlalchemy.orm.exc import NoResultFound
from flask.ext.github import GitHub

from libs.database_setup import Restaurant, MenuItem, User
from libs.database_setup import engine, start_session
from libs.secret import secret_key, GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET

#
# This is a Flask Web-App
#

app = Flask(__name__)
app.config['GITHUB_CLIENT_ID'] = GITHUB_CLIENT_ID
app.config['GITHUB_CLIENT_SECRET'] = GITHUB_CLIENT_SECRET


# CSRF token
def generate_csrf_token():
    if '_csrf_token' not in session:
        rand = str(random())
        session['_csrf_token'] = rand
    return session['_csrf_token']

app.jinja_env.globals['csrf_token'] = generate_csrf_token

# set up github-flask
github = GitHub(app)

# database session
Example #9
0
import collections

def update(d, u):
    for k, v in u.iteritems():
        if isinstance(v, collections.Mapping):
            r = update(d.get(k, {}), v)
            d[k] = r
        else:
            d[k] = u[k]
    return d


# Init the rcbuild.info app.
rcbuild = Flask(__name__)
sslify = SSLify(rcbuild, skips=["healthz"])
rcbuild.config['GITHUB_CLIENT_ID'] = os.environ['GITHUB_CLIENT_ID']
rcbuild.config['GITHUB_CLIENT_SECRET'] = os.environ['GITHUB_CLIENT_SECRET']
rcbuild.config['GITHUB_BASE_URL'] = os.environ['GITHUB_BASE_URL']
rcbuild.config['GITHUB_AUTH_URL'] = os.environ['GITHUB_AUTH_URL']
rcbuild.config['PROPAGATE_EXCEPTIONS'] = True
rcbuild.config['PERMANENT_SESSION_LIFETIME'] = 365 * 24 * 60 * 60
rcbuild.secret_key = os.environ['SESSION_SECRET_KEY']
application = rcbuild

FERNET_KEY = os.environ['FERNET_KEY']
f = Fernet(FERNET_KEY)

es = elasticsearch.Elasticsearch([os.environ['ES_HOST']])

SILENT_COMMIT_MESSAGE = "Silently upgrade - "
Example #10
0
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base

from circle import CircleCi

DATABASE_URI = 'sqlite:////tmp/github-flask.db'
SECRET_KEY = 'development key'
DEBUG = True


# setup flask
app = Flask(__name__)
app.config.from_object(__name__)
# Set these values
app.config['GITHUB_CLIENT_ID'] = '905ed692609686609213'
app.config['GITHUB_CLIENT_SECRET'] = '5ecff42c7336252b1c3e702ba19012bcd0576e7b'

# setup github-flask
github = GitHub(app)

# setup sqlalchemy
engine = create_engine(app.config['DATABASE_URI'])
db_session = scoped_session(sessionmaker(autocommit=False,
                                         autoflush=False,
                                         bind=engine))
Base = declarative_base()
Base.query = db_session.query_property()


def init_db():
from flask import Flask, render_template, 
request, redirect, url_for, jsonify, flash, g, session
from flask.ext.seasurf import SeaSurf

app = Flask(__name__)
csrf = SeaSurf(app)
# setup ssl if needed
"""import ssl
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.load_cert_chain('/etc/ssl/private/server.pem')"""

# setup client id and secret of github application for oauth 
from flask.ext.github import GitHub

# config application
app.config['GITHUB_CLIENT_ID'] = 'd9d0cb52ecbfe6eca444'
app.config['GITHUB_CLIENT_SECRET'] = '6d68058faf21c57f55944615b9af451bc209c6ec'
app_secret = 'ZZZ'
github_callback_url = "http://localhost:5000/github-callback"
github = GitHub(app)

# setup sqlalchemy
from sqlalchemy import create_engine, desc
from sqlalchemy.orm import sessionmaker,scoped_session
from database_setup import Base, Category, Item, User
engine = create_engine('sqlite:///catalog.db')

Base.metadata.bind = engine

# http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html#sqlalchemy.orm.scoping.scoped_session
db_session = scoped_session(sessionmaker(autocommit=False,
import os
from flask import Flask, flash, g, jsonify, redirect, render_template,\
                  request, session, url_for
from flask.ext.github import GitHub

app = Flask(__name__)
app.secret_key = "developmentkeyforthewin"

# set-up github oauth - https://github-flask.readthedocs.org/en/latest/
if os.environ.has_key('GITHUB_CLIENT_ID') and\
   os.environ.has_key('GITHUB_CLIENT_SECRET'):
    # set app configuration variables to environment variables
    app.config['GITHUB_CLIENT_ID'] = os.environ['GITHUB_CLIENT_ID']
    app.config['GITHUB_CLIENT_SECRET'] = os.environ['GITHUB_CLIENT_SECRET']
else:
    # set to None if they're not available
    app.config['GITHUB_CLIENT_ID'] = None
    app.config['GITHUB_CLIENT_SECRET'] = None
github = GitHub(app)

from database_setup import Base, User, Provider, Course
from datetime import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session

engine = create_engine('sqlite:///catalog.db')
Base.metadata.bind = engine

DBSession = scoped_session(sessionmaker(bind=engine))
db_session = DBSession()
Example #13
0
import os
import requests
from sqlalchemy import create_engine, Column, Integer, String, Boolean
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base


app = Flask(__name__)


if 'SENTRY_DSN' in os.environ:
    from raven.contrib.flask import Sentry
    sentry = Sentry(app)


app.config['GITHUB_CLIENT_ID'] = os.environ['AELITA_GITHUB_CLIENT_ID']
app.config['GITHUB_CLIENT_SECRET'] = os.environ['AELITA_GITHUB_CLIENT_SECRET']
app.config['BOT_USERNAME'] = os.environ['AELITA_BOT_USERNAME']
app.config['BOT_BASEURL'] = os.environ['AELITA_BOT_BASEURL']
app.config['BOT_DBURI'] = os.environ['AELITA_BOT_DBURI']
app.config['BOT_ACCESS_TOKEN'] = os.environ['AELITA_BOT_ACCESS_TOKEN']
app.config['BOT_NOTICE_SECRET'] = os.environ['AELITA_BOT_NOTICE_SECRET']
app.config['BOT_STATUS_SECRET'] = os.environ['AELITA_BOT_STATUS_SECRET']
app.secret_key = os.environ['AELITA_VIEW_SECRET']
github = GitHub(app)
engine = create_engine(app.config['BOT_DBURI'])
db_session = scoped_session(
    sessionmaker(
        autocommit=False,
        autoflush=False,
        bind=engine,
Example #14
0
from wtforms import StringField, SubmitField
from wtforms.validators import DataRequired

api_key_parser = reqparse.RequestParser()
api_key_parser.add_argument('api_key')

add_command_parser = api_key_parser.copy()
add_command_parser.add_argument('command')

app = Flask(__name__)
app.config['STANDALONE'] = os.environ.get('STANDALONE', False)
app.config['STANDALONE_USERNAME'] = os.environ.get('STANDALONE_USERNAME')
app.config['SECRET_KEY'] = os.environ['SECRET_KEY']
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL']
app.config['GITHUB_CLIENT_SECRET'] = os.environ['GITHUB_APP_SECRET']
app.config['GITHUB_CLIENT_ID'] = os.environ['GITHUB_APP_ID']
Bootstrap(app)
github = GitHub(app)
api = Api(app)


def url_for_other_page(page):
    args = request.view_args.copy()
    args['page'] = page
    return url_for(request.endpoint, **args)
app.jinja_env.globals['url_for_other_page'] = url_for_other_page


@github.access_token_getter
def token_getter():
    if current_user.is_authenticated():
config_key = ndb.Key(Config, "default")
config = config_key.get()
if not config:
  config = Config(key=config_key)
  config.put()

BS = 16
def pad(s):
  return s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
def unpad(s):
  return s[0:-ord(s[-1])]

AES_KEY = base64.b64decode(config.aes_key)

app.config['GITHUB_CLIENT_ID'] = config.github_client_id
app.config['GITHUB_CLIENT_SECRET'] = config.github_client_secret
app.config['PERMANENT_SESSION_LIFETIME'] = 365 * 24 * 60 * 60
app.secret_key = base64.b64decode(config.flask_session_secret)

from flask_github import GitHub

github = GitHub(app)

import contributor_discount

@app.route('/')
def index():
  template = JINJA_ENVIRONMENT.get_template('index.html')
  return template.render()
Example #16
0
# setup flask
from flask import Flask, render_template, request, redirect
from flask import url_for, jsonify, flash, g, session
from flask.ext.seasurf import SeaSurf
app = Flask(__name__)
csrf = SeaSurf(app)
# setup client id and secret of github application for oauth
from flask.ext.github import GitHub

# config application
app.config['GITHUB_CLIENT_ID'] = '5f27a275b15918f1233e'
app.config['GITHUB_CLIENT_SECRET'] = 'f11d899f97faf6cf3780667470501928ad0cd946'
app_secret = 'SECRET'
github_callback_url = "http://localhost:5000/github-callback"
github = GitHub(app)

# setup sqlalchemy
from sqlalchemy import create_engine, desc
from sqlalchemy.orm import sessionmaker, scoped_session
from database_setup import Base, Category, Item, User
engine = create_engine('sqlite:///catalog.db')

Base.metadata.bind = engine

db_session = scoped_session(sessionmaker(autocommit=False,
                                         autoflush=False,
                                         bind=engine))

Base.query = db_session.query_property()

Example #17
0
                raise GitHubError(response)
            if response.headers['Content-Type'].startswith('application/json'):
                result += response.json()
            else:
                raise GitHubError(response)
        return result
    else:
        return response


GitHub.request = patched_github_request

app = Flask(__name__)
app.secret_key = 'secret'
app.config['ORGANISATION'] = 'Kozea'
app.config['GITHUB_CLIENT_ID'] = '4891551b9540ce8c4280'
app.config['GITHUB_CLIENT_SECRET'] = 'bcfee82e06c41d22cd324b33a86c1e82a372c403'
app.config.from_envvar('GIBOLT_SETTINGS', silent=True)
app.config['TIMEZONE'] = 'Europe/Paris'


@app.template_filter('sort_by_len')
def sort_by_len(values, reverse=False):
    """Sort the ``values`` list by the length of its second item.```"""
    return sorted(values, key=lambda item: len(item[1]), reverse=reverse)


@app.template_filter('format_date')
def format_date_filter(isodate, dateformat):
    """Transform an ISO-date to a string following ``dateformat``."""
    numbers = [int(number) for number in isodate.split('-')]
Example #18
0
import datetime
import requests

app = Flask(__name__)

SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
fp = os.path.join(SITE_ROOT, 'config.json')
app = Flask(__name__)
global token
token = None
global user
user = None
with open(fp) as cred:
    creds = json.load(cred)

app.config['GITHUB_CLIENT_ID'] = creds['id']
app.config['GITHUB_CLIENT_SECRET'] = creds['secret']
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://localhost/challenges'
#heroku = Heroku(app)
github = GitHub(app)
db = SQLAlchemy(app)
CORS(app)

class Challenge(db.Model):
    __tablename__ = "challenges"
    id = db.Column(db.Integer, primary_key=True)
    user1 = db.Column(db.String(80))
    user2 = db.Column(db.String(80))
    start = db.Column(db.DateTime)
    def __init__(self, u1, u2, start):
        self.user1 = u1
Example #19
0
import json

from resources import EventResourceCreator, EventResourceMutator

from flask import Flask, request, url_for, flash
from flask.ext.restful import Api

from flask.ext.github import GitHub
from mongoengine import connect

# TODO: Some environment detection to swap the host
connect('foo_events', host='localhost', port=27017)

app = Flask(__name__)
app.config['GITHUB_CLIENT_ID'] = '7202ee64b544e635bdbb'
app.config['GITHUB_CLIENT_SECRET'] = '9c0df971624cb42ec6c3b1ecda41b6c9927d1756'
app.config['GITHUB_CALLBACK_URL'] = 'http://localhost/auth/github-callback'

api = Api(app)

# @app.route("/")
# def hello():
#     return "Hello World!"
#
#
# # api methods for Event API - this is the initial version thus v1
# @app.route('/api/v1/event', methods=['GET', 'PUT', 'POST', 'DELETE'])
# def event_new():
#     data = json.loads(request.data)
#     FooEvent.objects.create()
Example #20
0
        'css/oo-index.css',
    ),
}

app.config['JS_BUNDLES'] = {
    'bundle-js': (
        'js/jquery-2.1.0.js',
        'js/bootstrap.js',
    ),
}

Funnel(app)

try:
    app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', 'change-me')
    app.config['GITHUB_CLIENT_ID'] = os.environ['GITHUB_CLIENT_ID']
    app.config['GITHUB_CLIENT_SECRET'] = os.environ['GITHUB_CLIENT_SECRET']
except KeyError, ex:
    app.config['GITHUB_CLIENT_ID'] = 'FAKE-CLIENT-ID'
    app.config['GITHUB_CLIENT_SECRET'] = 'FAKE-CLIENT-SECRET'
    print >>sys.stderr, "Missing config: %s (Please fix)" % ex

try:
    if 'HOST' in os.environ:
        app.config['GITHUB_CALLBACK_URL'] = 'https://' + os.environ['HOST'] + '/login/callback'
    else:
        app.config['GITHUB_CALLBACK_URL'] = 'https://' + os.environ['OPENSHIFT_APP_DNS'] + '/login/callback'
except KeyError:
    app.config['GITHUB_CALLBACK_URL'] = 'http://localhost:5000' + '/login/callback'

# set it to point to your own oo-index public repo
Example #21
0
File: API.py Project: jce-il/SE-Hub
from SE_API.CampusRoutes import campus_routes
from SE_API.CourseRoutes import course_routes
from SE_API.ProjectRoutes import project_routes
from SE_API.TaskRoutes import task_routes
from SE_API.MessageRoutes import message_routes




app = Flask(__name__, static_folder='../templates')



githubKeys = GitHubAPI_Keys()

app.config['GITHUB_CLIENT_ID'] = githubKeys.getId()
app.config['GITHUB_CLIENT_SECRET'] = githubKeys.getSecret()

github = GitHub(app)
cross = CORS(app)

app.register_blueprint(user_routes)
app.register_blueprint(campus_routes)
app.register_blueprint(course_routes)
app.register_blueprint(project_routes)
app.register_blueprint(task_routes)
app.register_blueprint(message_routes)

auto = Autodoc(app)

@app.route('/')
Example #22
0
from flask import Flask, flash, g, jsonify, redirect, render_template, request, session, url_for
from flask.ext.github import GitHub
import requests

import db
import tracker

OWNER = 'danvk'
REPO = 'dygraphs'

app = Flask(__name__)

DEBUG = os.environ.get('DEBUG')
app.secret_key = os.environ.get('SECRET_KEY')
app.config['GITHUB_CLIENT_ID'] = os.environ.get('CLIENT_ID')
app.config['GITHUB_CLIENT_SECRET'] = os.environ.get('CLIENT_SECRET')

github = GitHub(app)


def format_date_column(series):
    '''Converts the first column of series to an ISO-8601 string'''
    out = []
    for row in series:
        out.append([row[0].strftime('%Y-%m-%dT%H:%M:%SZ')] + list(row[1:]))
    return out


def get_current_label_counts(by_label):
    '''Returns an ordered list of (label, count) tuples.'''
Example #23
0
# got idea for github login from https://github.com/cenkalti/github-flask/blob/master/example.py
# github-flask login code from https://github-flask.readthedocs.org/en/latest/

from flask import Flask, render_template, request, redirect, url_for, jsonify, flash, g, session
app = Flask(__name__)


from flask.ext.github import GitHub

# config github login and app secret
app.config['GITHUB_CLIENT_ID'] = '6082ec605cd87c9c44ed'
app.config['GITHUB_CLIENT_SECRET'] = '2c96e4962140f731ce49789407a8f9953787984d'
github_callback_url = "http://localhost:5000/callback"
github = GitHub(app)
app_secret = 'SuperSecretKey'

from sqlalchemy import create_engine, desc
from sqlalchemy.orm import sessionmaker,scoped_session
from database_setup import Base, Category, Item, User
engine = create_engine('sqlite:///catalog.db')

Base.metadata.bind = engine

db_session = scoped_session(sessionmaker(
	autocommit=False,
	autoflush=False,
	bind=engine))

Base.query = db_session.query_property()

# create routes
Example #24
0
import boto
from boto.s3.key import Key


def connect_db():
	g.conn = psycopg2.connect(database="MODIFY", user="MODIFY", password="MODIFY", host="MODIFY", port="MODIFY")
	g.cur = g.conn.cursor()
	
def close_db():
	g.conn.close()
	g.cur.close()
	
	
#setup for GitHub login using Client ID and Client Secret
app = Flask(__name__)
app.config['GITHUB_CLIENT_ID'] = 'MODIFY'
app.config['GITHUB_CLIENT_SECRET'] = 'MODIFY'
app.secret_key = 'MODIFY'
app.config['AWS_ACCESS_KEY_ID'] = 'MODIFY'
app.config['AWS_SECRET_ACCESS_KEY'] = 'MODIFY'

Markdown(app)
github = GitHub(app)

# Variables

# These indicate which page has focus
showroomStatus = ''
aboutStatus = ''
projectStatus = ''
homeStatus = ''
Example #25
0
import pylru

import base64
import copy
import requests
import json
import hmac
import math
import urllib
import urlparse
from hashlib import sha1

import collections

rcpart = Flask(__name__)
rcpart.config['GITHUB_CLIENT_ID'] = os.environ['GITHUB_CLIENT_ID']
rcpart.config['GITHUB_CLIENT_SECRET'] = os.environ['GITHUB_CLIENT_SECRET']
rcpart.config['GITHUB_BASE_URL'] = os.environ['GITHUB_BASE_URL']
rcpart.config['PROPAGATE_EXCEPTIONS'] = True
application = rcpart

es = elasticsearch.Elasticsearch([os.environ['ES_HOST']])

partCategories_string = ""
partCategories = {}

github_cache = pylru.lrucache(64)

from git import Repo

github = GitHub(rcpart)
Example #26
0
urlfetch.set_default_fetch_deadline(45)

import requests
from requests.auth import HTTPBasicAuth
import json
from datetime import datetime
import operator
import math
import os

from private.secret import Secret
secret = Secret()
app.secret_key = secret.session_secret

from flask.ext.github import GitHub
app.config['GITHUB_CLIENT_ID'] = secret.github_client_id
app.config['GITHUB_CLIENT_SECRET'] = secret.github_client_secret
github = GitHub(app)


@app.route('/', methods=["GET"])
def index():
    return render_template("index.html", is_logged_in=is_logged_in())

@app.route('/login')
def login():
    return github.authorize()

@app.route('/logout')
def logout():
    if "access_token" in session:
Example #27
0

app = Flask(__name__)
app.config.from_object(configuration)
try:
    app.config.from_object('local_settings')
except:
    pass

babel = Babel(app)
mail = Mail(app)
db = SQLAlchemy(app)

try:
    with open('githubsecrets.txt') as f:
        app.config['GITHUB_CLIENT_ID'] = f.readline().strip()
        app.config['GITHUB_CLIENT_SECRET'] = f.readline().strip()
    github = GitHub(app)
except:
    pass

from app import forms
from app import models
from app import render
from app import views

from flask_admin import Admin
from flask_admin.contrib.sqla import ModelView
from app.models import User, Patch, Role, Submitter, Project, Comment, Series, Topic, Tag

from flask.ext.whooshalchemy import whoosh_index
Example #28
0
import os
from flask import Flask, request, session, g, redirect, url_for, abort, \
     render_template, flash
from flask_github import GitHub

# create our little application :)
app = Flask(__name__)
app.config.from_object(__name__)
app.config['GITHUB_CLIENT_ID'] = '60bd3707a2d6e88cb7b4'
app.config['GITHUB_CLIENT_SECRET'] = 'c9f263852a9d926d67504b39b739643ab5a174ce'

github = GitHub(app)

# Load default config and override config from an environment variable
app.config.update(dict(
    DATABASE=os.path.join(app.root_path, 'emoji.db'),
    SECRET_KEY='d3v3l0pm3nt k3y',
    USERNAME='admin',
    PASSWORD='a55w0rd',
    APIURL='https://api.github.com/emojis'
))
app.config.from_envvar('EMOJI_SETTINGS', silent=True)