Example #1
0
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.uploads import UploadSet, configure_uploads, IMAGES, patch_request_class, UploadConfiguration
from flask_oauthlib.client import OAuth
from app.misc.easemob import Easemob

app = Flask(__name__)
app.config.from_object('config')
app.config.update(
    UPLOADS_DEFAULT_DEST = PHOTO_BASE_DIR
)
app.config['OAUTH_CREDENTIALS'] = {
    'qq': {
	#qq open platform uses 'key' instead of 'secret'
        'id': '1105136607',
        'secret': 'd9EKBHt0jYVJJn9v'
    },
    'wechat': {
        'id': '',
        'secret': ''
    }
}

app.secret_key = 'development'
oauth = OAuth(app)

qq = oauth.remote_app(
    'qq',
    consumer_key = QQ_APP_ID,
    consumer_secret = QQ_APP_KEY,
    base_url = 'https://graph.qq.com',
    request_token_url = None,
Example #2
0
import os
import secrets

from flask import Flask, url_for
from flask.ext.mongoengine import MongoEngine
from flask.ext.login import LoginManager
app = Flask(__name__)


app.config['DEBUG'] = True # Enable this only while testing!
app.config['MONGODB_SETTINGS'] = { 'db': 'musicwebs' }
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': secrets.FACEBOOK_ACCESS_KEY_ID,
        'secret': secrets.FACEBOOK_SECRET_KEY
    }
}
app.config['SECRET_KEY'] = secrets.SECRET_KEY

db = MongoEngine(app)

# Associate Flask-Login manager with current app
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = "login.index"

@login_manager.user_loader
def load_user(user_id):
    from app.models.user import User
    return User.objects().get(id=user_id)
Example #3
0
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config.from_object('config')

app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': '524423207723710',
        'secret': '5ee856ba60c176c2201b70165dbb60fa'
    }
}

db = SQLAlchemy(app)

from app import views, models
Example #4
0
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager, UserMixin, login_user, logout_user,\
    current_user
from oauth import OAuthSignIn


app = Flask(__name__)
app.config['SECRET_KEY'] = 'superhemmelig!'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': '<app id her>',
        'secret': '<app secret her>'
        },
    'twitter': {
        'id': '<app id her>',
        'secret': '<app secret her>'
        },
    'google': {
        'id': '<app id som ender i .apps.googleusercontent.com her>',
        'secret': '<app secret her'
        }
    }


db = SQLAlchemy(app)
lm = LoginManager(app)
lm.login_view = 'index'


class User(UserMixin, db.Model):
    __tablename__ = 'users'
    ch.setFormatter(formatter)
    logger.addHandler(ch)


logger = logging.getLogger(__name__)
setup_logger(logger)
logger.setLevel(logging.DEBUG)
logger.info('completed logger config. beginning to load application.')

app = Flask(__name__)
app.config.from_object('config')


try:
    from local_settings import OAUTH_CREDS
    app.config['OAUTH_CREDENTIALS'] = OAUTH_CREDS

except ImportError, e:
    pass

# Attempting to set up engine here:

db = SQLAlchemy(app)
engine = db.engine
db_session = db.session

lm = LoginManager()
lm.init_app(app)
oid = OpenID(app, os.path.join(basedir, 'tmp'))

from app import views, models
Example #6
0
from flask import Flask
from sqlalchemy import DDL, event
from flask.ext.login import LoginManager, UserMixin
from flask.ext.sqlalchemy import SQLAlchemy
import settings

import flask_admin as admin
from flask_admin.contrib import sqla
from flask_admin.contrib.sqla import filters

app = Flask(__name__)
app.config['SECRET_KEY'] = settings.SECRET_KEY
app.config['SQLALCHEMY_DATABASE_URI'] = settings.SQLALCHEMY_DATABASE_URI
app.config['OAUTH_CREDENTIALS'] = settings.OAUTH_CREDENTIALS

db = SQLAlchemy(app)
login_manager = LoginManager(app)
login_manager.login_view = 'index'


# SQLAlchemy classes that reference to tables
# user_pofile, status, async_operation
class Users(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    facebook_id = db.Column(db.String(64), nullable=False, unique=True)
    username = db.Column(db.String(80), nullable=True, unique=True)
    first_name = db.Column(db.String(64), nullable=True)
    last_name = db.Column(db.String(64), nullable=True)
    email = db.Column(db.String(64), nullable=True)

    def __unicode__(self):
Example #7
0
from flask import Flask, redirect, url_for, render_template
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager, UserMixin, login_user, logout_user,\
    current_user
from oauth import OAuthSignIn


app = Flask(__name__)
app.config['SECRET_KEY'] = 'top secret!'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': '1709784175945720',
        'secret': 'bedcffed13824a9a0f0e66d8b8d33c5b'
    },
    'twitter': {
        'id': 'MCL5Ws8CmWBc8FTmBFHMuh2Jg',
        'secret': 'eWMYc9LpkQt52TWwFKT54sZywyz9SJFR6baiPW7DROYOHKxHJO'
    }
}

db = SQLAlchemy(app)
lm = LoginManager(app)
lm.login_view = 'index'


class User(UserMixin, db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    social_id = db.Column(db.String(64), nullable=False, unique=True)
    nickname = db.Column(db.String(64), nullable=False)
Example #8
0
from wtforms import StringField, PasswordField
from flask_wtf import Form
from wtforms.validators import DataRequired, Regexp, ValidationError, Email, Length
from search_tag import search_to_json
from twitter import get_keywords_twitter


app = Flask(__name__)
app.logger.addHandler(logging.StreamHandler(sys.stdout))
app.logger.setLevel(logging.ERROR)
app.config['SECRET_KEY'] = 'secret'
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL']  #'sqlite:///esoteric.sqlite' #
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': '',
        'secret': ''
    }
}

db = SQLAlchemy(app)


login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'login'


class User(db.Model, UserMixin):
    __tablename__ = 'users'

    id = db.Column(db.BIGINT, primary_key=True)
Example #9
0
from wtforms.validators import DataRequired
import os
from werkzeug import secure_filename
import flask.ext.login as flask_login
import bcrypt
from rauth import OAuth2Service

# Initialize the Flask application and set configurations
bottlecapp = Flask(__name__)
bottlecapp.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
bottlecapp.config['SECRET_KEY'] = 'important to keep unknown in production' # for form
bottlecapp.config['UPLOAD_FOLDER'] = 'static/caps/'
bottlecapp.config['ALLOWED_EXTENSIONS'] = set(['png'])
bottlecapp.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': '1694391720826669',
        'secret': '013d8ade6b15271054f551b31f309231'
    }
}

# create db instance and bind it to the app
db = SQLAlchemy(bottlecapp)  

# set up the login manager by instantiating it and telling it about the app
login_manager = flask_login.LoginManager()
login_manager.init_app(bottlecapp)

# rauth OAuth 2.0 service wrapper
facebook = OAuth2Service(
    name = 'facebook',
    client_id = bottlecapp.config['OAUTH_CREDENTIALS']['facebook']['id'],
    client_secret = bottlecapp.config['OAUTH_CREDENTIALS']['facebook']['secret'],
Example #10
0
from flask import Flask, redirect, url_for, render_template
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager, UserMixin, login_user, logout_user,\
    current_user
from oauth import OAuthSignIn


app = Flask(__name__)
app.config['SECRET_KEY'] = 'top secret!'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': '470154729788964',
        'secret': '010cc08bd4f51e34f3f3e684fbdea8a7'
    },
    'twitter': {
        'id': '3RzWQclolxWZIMq5LJqzRZPTl',
        'secret': 'm9TEd58DSEtRrZHpz2EjrV9AhsBRxKMo8m3kuIZj3zLwzwIimt'
    }
}

db = SQLAlchemy(app)
lm = LoginManager(app)
lm.login_view = 'index'


class User(UserMixin, db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    social_id = db.Column(db.String(64), nullable=False, unique=True)
    nickname = db.Column(db.String(64), nullable=False)
Example #11
0
from  datetime import datetime, time
from findARestaurant import findARestaurant

engine = create_engine('sqlite:///meatneat.db')

Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()
app = Flask(__name__)
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
          'id': '470154729788964',
          'secret': '010cc08bd4f51e34f3f3e684fbdea8a7'
      },
      'google': {
          'id': '763910754530-rqig5i0qt95f2832bdkg15m49580rhtl.apps.googleusercontent.com',
          'secret': 'KA5kZILEXedg8SuQsied7MfW'
      },
      'twitter': {
          'id': '3RzWQclolxWZIMq5LJqzRZPTl',
          'secret': 'm9TEd58DSEtRrZHpz2EjrV9AhsBRxKMo8m3kuIZj3zLwzwIimt'
      },
}


@auth.verify_password
def verify_password(username_or_token, password):
    #Try to see if it's a token first
    user_id = User.verify_auth_token(username_or_token)
    if user_id:
        user = session.query(User).filter_by(id = user_id).one()
    else:
from datetime import timedelta
from oauth import OAuthSignIn
from flask.ext.login import LoginManager, UserMixin, login_user, logout_user,\
    current_user


app = Flask(__name__)

app.config.from_object('config')

app.config['SECRET_KEY'] = 'top secret!'
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': '1499036657056554',
        'secret': '3e5ab24b3a181b79fabe61262b27994e'
    },
    'twitter': {
        'id': '3RzWQclolxWZIMq5LJqzRZPTl',
        'secret': 'm9TEd58DSEtRrZHpz2EjrV9AhsBRxKMo8m3kuIZj3zLwzwIimt'
    }
}

db = SQLAlchemy(app)

auth = HTTPBasicAuth()


from models import *


@auth.error_handler
def unauthorizedaccess():
# Flask configuration
app = Flask(__name__)

# restful, usrdb and login_manager instance
api = Api(app)
usrdb = SQLAlchemy(app)
lm = LoginManager(app)

lm.login_view = 'index'
lm.session_protection = 'strong'
app.config['SECRET_KEY'] = 'top secret!'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'

confidenceLevel = 2
dname = "linkVerification"

if devmode:
    app.config['OAUTH_CREDENTIALS'] = {
        'facebook': {
            'id': '622058264638304',
            'secret': '56bba85a0bef4cae8d07537701bbfe1f'
        }
    }
else:
    app.config['OAUTH_CREDENTIALS'] = {
        'facebook': {
            'id': '621200901380211',
            'secret': '0afb04701e956a3cf74ac876560e7041'
        }
    }
Example #14
0
from flask import Flask, redirect, url_for, render_template
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager, UserMixin, login_user, logout_user,\
    current_user
from oauth import OAuthSignIn


app = Flask(__name__)
app.config['SECRET_KEY'] = 'top secret!'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
app.config['OAUTH_CREDENTIALS'] = {
    'twitter': {
        'id': 'jQTWuIKosRdiQfOSVN9K3PMlW',
        'secret': 'UuCrRYK8s4i2L7t2wkK3DRjwgE9kjY83smDnvohH0f5I3V9aql'
    }
}

db = SQLAlchemy(app)
lm = LoginManager(app)
lm.login_view = 'index'


class User(UserMixin, db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    social_id = db.Column(db.String(64), nullable=False, unique=True)
    nickname = db.Column(db.String(64), nullable=False)
    email = db.Column(db.String(64), nullable=True)


@lm.user_loader
Example #15
0

context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.load_cert_chain('ssl.cert', 'ssl.key')


app = Flask(__name__)
app.config['SECRET_KEY'] = 'top secret!'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': '470154729788964',
        'secret': '010cc08bd4f51e34f3f3e684fbdea8a7'
    },
    'twitter': {
        'id': '3RzWQclolxWZIMq5LJqzRZPTl',
        'secret': 'm9TEd58DSEtRrZHpz2EjrV9AhsBRxKMo8m3kuIZj3zLwzwIimt'
    },
    'github': {
        'id': '4bef2e3fc12840fe9b17',
        'secret': '487964cbd9b2a2e2cf5c1b5945871ed732d697f3'
    }
}

db = SQLAlchemy(app)
lm = LoginManager(app)
lm.login_view = 'index'


class User(UserMixin, db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
Example #16
0
from flask import Flask, redirect, url_for, render_template, flash
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager, UserMixin, login_user, logout_user,\
    current_user
from oauth import OAuthSignIn


app = Flask(__name__)
app.config['SECRET_KEY'] = 'top secret!'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': '1443828952597505',
        'secret': '296511ffe34ae6f13ae9b56ec35c4818'
    }
}

db = SQLAlchemy(app)
lm = LoginManager(app)
lm.login_view = 'index'


class User(UserMixin, db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    social_id = db.Column(db.String(64), nullable=False, unique=True)
    nickname = db.Column(db.String(64), nullable=False)
    email = db.Column(db.String(64), nullable=True)


@lm.user_loader
Example #17
0
from flask.ext.login import LoginManager, UserMixin, login_user, logout_user, current_user
from common.auth.oauth import OAuthSignIn

# app configs
app = Flask(__name__)
app.config['SECRET_KEY'] = 'foobar'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': '938390016183772',
        'secret': '1a6e682707f7450dc04bd551be013d7a'
    },
    'twitter': {
        'id': 'RS8CVzwglN6pGDEI77K3KxsU5',
        'secret': 'i4Tqgxsq6vfK0qDEp3rVxcj3oKVqUq1cgL44pgvt3EEJraH3yz'
    },
    'dropbox': {
        'id': 'jjgd6gkjgn9j5xo',
        'secret': 'gcet2da11ev8vdd'
    },
    'gdrive': {
        'id': '33233782324-b7k9n5apa7roks02ihb36v637bvn9lkb.apps.googleusercontent.com',
        'secret': 'JBcjXfUZl--aliWjp1M1P9UU'
    }
}

# app managers
db = SQLAlchemy(app)    # db manager
lm = LoginManager(app)  # login manager
lm.login_view = 'index'

# User class - TODO: move to models/
Example #18
0
from flask import Flask

app = Flask(__name__, static_url_path='/static')
from app import views
from credentials import fb_credentials,twitter_credentials

#app.secret_key = 'thisisarandomstring007becauseilovejamesbond'
app.config['SECRET_KEY'] = 'thisisarandomstring007becauseilovejamesbond'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': fb_credentials['app_id'],
        'secret': fb_credentials['app_secret']
    },
    'twitter': {
        'id': twitter_credentials['consumer_key'],
        'secret': twitter_credentials['consumer_secret']
    }
}

Example #19
0
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
import config

app = Flask(__name__)
app.config.from_object('config')
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': config.FB_ID,
        'secret': config.FB_SECRET
    }
}
db = SQLAlchemy(app)

from app import views, models
import os
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager
from config import basedir
from flask.ext.mail import Mail

app = Flask(__name__)
app.config.from_object('config')
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': '1771436973087378',
        'secret': '71bdb49d9fb9b6f856dcf51e63523ace'
    },
    'twitter': {
        'id': ' thR3b6CKN9sBT9aA2OifIGtjj',
        'secret': 'sXsiLQHZCWtkGbRXkm3C9glbnHlFZahzdJ3JR4RkXghhWRb5DM'
    }
}
db = SQLAlchemy(app)

lm = LoginManager()
lm.init_app(app)
lm.login_view = 'login'

mail = Mail(app)

from dowell import views, models
Example #21
0
import base64
import json
import os
import shutil
import tempfile

import parser

DEBUG = False
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret'
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': '604820106335654',
        'secret': '5eb3f15f84c722df9cbc577206557cc8'
    },
    'twitter': {
        'id': 'cGFr2WV93py7an7FrGXXNDS6p',
        'secret': 'U9ufkrhicVHrj5CGojmQ7ZCxSwytoShSgM0t9WCq0HbqcfKwL8'
    }
}
app.secret_key = 'fe2917b485cc985c47071f3e38273348' # echo team paddy paddy | md5sum
app.config['UPLOAD_FOLDER'] = 'userFiles/'
app.config['ALLOWED_EXTENSIONS'] = set(['pml'])


def get_resource_as_string(name, charset='utf-8'):
    with app.open_resource(name) as f:
        return f.read().decode(charset)
app.jinja_env.globals['get_resource_as_string'] = get_resource_as_string

def allowed_file(filename):
Example #22
0
# from flask import session as login_session
# Flask login_session was not being used
from flask_login import LoginManager, UserMixin, login_user, logout_user, current_user, login_required
from oauth import OAuthSignIn
import random
import string
import json
import requests
from datetime import datetime

app = Flask(__name__)
app.config['SECRET_KEY'] = ''.join(random.choice(
    string.ascii_uppercase + string.digits) for x in xrange(32))
app.config['OAUTH_CREDENTIALS'] = {
    'google': {
        'id': '676777814958-qekn2togfmb9bpnbvfar9g9haar1d0gj.apps.googleusercontent.com',
        'secret': 'o_ivY_sLiV_BzT4L6IB0AxfO'
    }
}

lm = LoginManager(app)
lm.login_view = 'login'

engine = create_engine('sqlite:///itemcatalogue.db')
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()


@lm.user_loader
def load_user(id):
    return session.query(User).get(int(id))
Example #23
0
import cgi
import json
import elFinder
from subprocess import Popen, PIPE

import os,sys,inspect
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
print parentdir
import kerberos_client

app = Flask(__name__)
app.config['OAUTH_CREDENTIALS'] = {
    'ok_server' : {
        'id' : 'max_client_2',
        'secret' : "W6b4FSwb9J3jSo6IB+ijIXVEvqIOPLsN" #CONFIG.client_secret
    }
}

@app.route('/')
def index():
    if 'authenticated' in session:
        return redirect(url_for('authenticated'))

    return render_template('index.html')

@app.route('/connector',methods=['GET', 'POST'])
def connector():


    # configure per request connector options
Example #24
0
import os
from flask import Flask, redirect, url_for, render_template
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager, UserMixin, login_user, logout_user, current_user
from flask.ext.openid import OpenID
from oauth import OAuthSignIn
from config import basedir

app = Flask(__name__)
app.config.from_object('config')
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': '999659110055225',
        'secret': '36550d360347e840e6a018739664700d'
    }
}


db = SQLAlchemy(app)
lm = LoginManager()
lm.init_app(app)
lm.login_view = 'login'
oid = OpenID(app, os.path.join(basedir, 'tmp'))

from app import views, models
Example #25
0
assets.register('css_app', appcss)

appjs = Bundle('js/data.js', 'js/app.js', 'js/navbar.js', filters='jsmin', output='gen/app.js')
libsjs = Bundle('js/_libs/jquery/jquery-2.2.0.min.js', 'js/_libs/nunjucks.min.js', 'js/_libs/canvas-to-blob.min.js',
                'js/_libs/load-image.all.min.js', 'js/_libs/backbone/underscore-min.js',
                'js/_libs/backbone/backbone-min.js', 'js/_libs/backbone/backbone.localStorage-min.js', filters='jsmin',
                output='gen/libs.js')
assets.register('js_app', appjs)
assets.register('js_libs', libsjs)

app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': os.environ['FACEBOOK_AUTH'],
        'secret': os.environ['FACEBOOK_AUTH_SECRET']
    },
    'google': {
        'id': os.environ['GOOGLE_AUTH'],
        'secret': os.environ['GOOGLE_AUTH_SECRET'],
        'immediate': 'true'
    }
}

if not app.debug and MAIL_SERVER != '':
    import logging
    from logging.handlers import SMTPHandler
    credentials = None
    if MAIL_USERNAME or MAIL_PASSWORD:
        credentials = (MAIL_USERNAME, MAIL_PASSWORD)
    mail_handler = SMTPHandler((MAIL_SERVER, MAIL_PORT),
                               'no-reply@' + MAIL_SERVER, ADMINS,
                               'homeporch failure', credentials)
# See the README.md for more instructions.

import os

oauthIdsAndSecrets = {
    'facebook': {
        'id': os.environ['FACEBOOK_APP_ID'],
        'secret': os.environ['FACEBOOK_APP_SECRET'],
    },
}


app = Flask(__name__)
app.config['SECRET_KEY'] = os.environ['SESSION_SECRET']
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL']
app.config['OAUTH_CREDENTIALS'] = oauthIdsAndSecrets

db = SQLAlchemy(app)
lm = LoginManager(app)
lm.login_view = 'index'


class User(UserMixin, db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    social_id = db.Column(db.String(64), nullable=False, unique=True)
    nickname = db.Column(db.String(64), nullable=False)
    email = db.Column(db.String(64), nullable=True)


@lm.user_loader
from flask.ext.httpauth import HTTPBasicAuth
auth = HTTPBasicAuth()

import random,string
from  datetime import datetime, time
from findARestaurant import findARestaurant

engine = create_engine('sqlite:///meatneat.db')

Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()
app = Flask(__name__)
app.config['OAUTH_CREDENTIALS'] = {
      'google': {
          'id': '763910754530-rqig5i0qt95f2832bdkg15m49580rhtl.apps.googleusercontent.com',
          'secret': 'KA5kZILEXedg8SuQsied7MfW'
      },  
}


@auth.verify_password
def verify_password(username_or_token, password):
    #Try to see if it's a token first
    user_id = User.verify_auth_token(username_or_token)
    if user_id:
        user = session.query(User).filter_by(id = user_id).one()
    else:
        user = session.query(User).filter_by(username = username_or_token).first()
        if not user or not user.verify_password(password):
            return False
    g.user = user
    logout_user, current_user, login_required
from oauth import OAuthSignIn
from flask.ext.seasurf import SeaSurf
import json


app = Flask(__name__)
# Create a Login Manager instance for the log in and log out of users
login_manager = LoginManager(app)
csrf = SeaSurf(app)

# Base configuration. Probably better on an external file?
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///game_characters_menu.db'
app.config['OAUTH_CREDENTIALS'] = {
    'google': {
        'id': '''329604591768-jeq2ugfhdfm6r6324arcckmdamdr5g36\
.apps.googleusercontent.com''',
        'secret': 'tWckctJkAaUY4x-8Tedjc1c7'}}

engine = create_engine(app.config["SQLALCHEMY_DATABASE_URI"])
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()


@app.route("/")
def redirectToGames():
    """
    Redirects to main page, games.
    """
    return redirect("/games/")
Example #29
0
from flask import Flask
from sqlalchemy import DDL, event
from flask.ext.login import LoginManager, UserMixin
from flask.ext.sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SECRET_KEY'] = 'top secret!' 
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': 'replace with your client id',
        'secret': 'replace with your client secret'
    }
}


db = SQLAlchemy(app)
login_manager = LoginManager(app)
login_manager.login_view = 'index'


# SQLAlchemy classes that reference to tables
# user_pofile, status, async_operation
class UserProfile(UserMixin, db.Model):
    __tablename__ = 'user_profile'
    id = db.Column(db.Integer, primary_key=True)
    facebook_id = db.Column(db.String(64), nullable=False, unique=True)
    first_name = db.Column(db.String(64), nullable=True)
    last_name = db.Column(db.String(64), nullable=True)
    email = db.Column(db.String(64), nullable=True)
Example #30
0
from flask import Flask, redirect, url_for, render_template
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager, UserMixin, login_user, logout_user,\
    current_user
from oauth import OAuthSignIn


app = Flask(__name__)
app.config['SECRET_KEY'] = 'top secret!'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
        'id': '[INSERT FB APP ID]',
        'secret': '[INSERT FB SECRET]'
    },
    'mlh': {
        'id': '[INSERT MyMLH APP ID]',
        'secret': '[INSERT MyMLH SECRET]'
    }
}

db = SQLAlchemy(app)
lm = LoginManager(app)
lm.login_view = 'index'


class User(UserMixin, db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    social_id = db.Column(db.String(64), nullable=False, unique=True)
    nickname = db.Column(db.String(64), nullable=False)