def setup_app(): app = Flask(__name__) app.config.update( GOOGLE_LOGIN_CLIENT_ID=settings.GOOGLE_LOGIN['CLIENT_ID'], GOOGLE_LOGIN_CLIENT_SECRET=settings.GOOGLE_LOGIN['CLIENT_SECRET'], GOOGLE_LOGIN_REDIRECT_URI=settings.GOOGLE_LOGIN['REDIRECT_URI'], GOOGLE_LOGIN_SCOPES='email', SECRET_KEY='hackathing_secret') db.init_app(app) return app, GoogleLogin(app=app)
users = {} app = Flask(__name__, static_url_path='', static_folder='static', template_folder='static') app.config.update( SECRET_KEY='SECRETSECRETKEY', GOOGLE_LOGIN_CLIENT_ID= '207581121170-6ja4pfdp9ec09l2b3g0ufb9c2pk42k9o.apps.googleusercontent.com', GOOGLE_LOGIN_CLIENT_SECRET='Fahbsf_7hbKxnGUgaN3Z_s4x', GOOGLE_LOGIN_REDIRECT_URI='http://*****:*****@app.route("/") def index(): return app.send_static_file('index.html') @app.route("/speakers") def speakers(): return redirect("/#3")
app.config.update( DEBUG=os.environ.get('DEBUG', False), SECRET_KEY=os.environ.get('SECRET_KEY', ''), GOOGLE_LOGIN_CLIENT_ID=os.environ.get('GOOGLE_LOGIN_CLIENT_ID', ''), GOOGLE_LOGIN_CLIENT_SECRET=os.environ.get('GOOGLE_LOGIN_CLIENT_SECRET', ''), GOOGLE_LOGIN_REDIRECT_URI=os.environ.get('GOOGLE_LOGIN_REDIRECT_URI', ''), SQLALCHEMY_DATABASE_URI=os.environ.get('SQLALCHEMY_DATABASE_URI', ''), ) db = SQLAlchemy(app) # setup assetbundle assets = Environment(app) assets.debug = True if app.debug == 'True' else False bundles = PythonLoader('newbeercellar.assetbundles').load_bundles() for name, bundle in bundles.iteritems(): assets.register(name, bundle) # setup login stuff login_manager = LoginManager() login_manager.init_app(app) googlelogin = GoogleLogin(app, login_manager) # add various views from newbeercellar import login from newbeercellar import views from newbeercellar import api app.db_session = db.session
# app.permanent_session_lifetime = timedelta(seconds=1200) # login_manager = LoginManager() # login_manager.init_app(app) # login_manager.login_view = 'home' app.config.update( SECRET_KEY='AIzaSyBBT8JaFtFr2Gknpe5GxvhYMWdxkxULHSc', GOOGLE_LOGIN_CLIENT_ID= '667156749456-lbd0uctkmb0vscjn2q0e1420f20fu435.apps.googleusercontent.com', GOOGLE_LOGIN_CLIENT_SECRET='TOTRxDbDVTyC-I3uZ0ATX3kJ', GOOGLE_LOGIN_REDIRECT_URI='http://localhost:9090/user/oauth2callback' # GOOGLE_LOGIN_REDIRECT_URI='http://fdt.accentcom.agency/user/oauth2callback' ) google_login = GoogleLogin(app) # function for jinja2 import function app.url_map.converters['objectid'] = function.ObjectIDConverter app.jinja_env.filters['format_date'] = function.format_date app.jinja_env.filters['format_date_month'] = function.format_date_month app.jinja_env.filters['add_time'] = function.add_time app.jinja_env.filters['format_price'] = function.format_price app.jinja_env.filters['get_first_day'] = function.get_first_day app.jinja_env.filters['get_last_day'] = function.get_last_day app.jinja_env.filters['string'] = function.string # Pull in URL dispatch routes import urls
from smokerlib import * from sqlalchemy import desc import smokerconfig import sys app = Flask(__name__) app.secret_key = smokerconfig.sessionsecret app.config["GOOGLE_LOGIN_CLIENT_ID"] = smokerconfig.google_client_id app.config["GOOGLE_LOGIN_CLIENT_SECRET"] = smokerconfig.google_client_secret #app.config["GOOGLE_LOGIN_SCOPES"] = "" app.config["GOOGLE_LOGIN_REDIRECT_URI"] = smokerconfig.apibaseurl + "/oauth2callback" app.config["GOOGLE_LOGIN_REDIRECT_SCHEME"] = "https" app.debug = False googlelogin = GoogleLogin() googlelogin.init_app(app) if not app.debug: import logging from logging.handlers import RotatingFileHandler file_handler = RotatingFileHandler("/websites/applogs/smokerapi.log",maxBytes=10*2**20,backupCount=7) file_handler.setLevel(logging.DEBUG) app.logger.setLevel(logging.DEBUG) app.logger.addHandler(file_handler) @app.teardown_appcontext def close_db(error): database.db_session.remove() if hasattr(g,'database'): g.database.close()
a837dbf490d67e1908f77664151875382915e598 ' app.config[ 'GOOGLE_LOGIN_CLIENT_ID'] = '594813004745-1hcngg3mvnl0pur2rm6qtlo3agevaa7m.apps.googleusercontent.com' app.config['GOOGLE_LOGIN_CLIENT_SECRET'] = 'gn-Hg1txIHtffY-cjDXJ0p-v' app.config['GOOGLE_LOGIN_SCOPES'] = 'openid email profile' app.config['GOOGLE_LOGIN_REDIRECT_SCHEME'] = "http" app.config[ 'GOOGLE_LOGIN_REDIRECT_URI'] = "https://localhost:8080/oauth2callback" app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True database = SQLAlchemy() database.init_app(app) login_manager = LoginManager() login_manager.init_app(app) google_login = GoogleLogin() google_login.init_app(app, login_manager) class User(UserMixin, database.Model): id = database.Column(database.Integer, primary_key=True) name = database.Column(database.String(256)) picture = database.Column(database.String(256)) google_id = database.Column(database.String(256)) facebook_id = database.Column(database.String(256)) @login_manager.user_loader def standard_user_loader(user_id): return User.query.get(user_id)
# Create flask app app = Flask(__name__, static_url_path="") app.config.update( # https://code.google.com/apis/console GOOGLE_LOGIN_SCOPES='email,profile', DEBUG=True) login_manager = LoginManager() @login_manager.user_loader def user_loader(user_id): return User.query.get(user_id) googlelogin = GoogleLogin(app, login_manager) googlelogin.user_loader(user_loader) # setup sqlalchemy db_session = None Base = declarative_base() def init_db(): engine = create_engine(app.config['DATABASE_URI'], echo=True) global db_session global Base db_session = scoped_session( sessionmaker(autocommit=False, autoflush=True, bind=engine)) Base.query = db_session.query_property() Base.metadata.create_all(bind=engine)