# from flask.ext.sqlalchemy import SQLAlchemy

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

from catalog.models import Base


app = Flask(__name__)

# App root folder
app_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))

# Load client ids from config files
client_secret = os.path.join(app_root, "client_secret_google.json")
app.config["GOOGLE_CLIENT_ID"] = json.loads(open(client_secret, "r").read())["web"]["client_id"]


# Configuration
# app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql:///catalog'
# app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config["SECRET_KEY"] = "super_secret_key"
app.config["CSRF_SECRET_KEY"] = "csfr_super_secret_key"
app.config["UPLOAD_FOLDER"] = os.path.join(app_root, "uploads")
app.config["ALLOWED_IMAGE_EXTENSIONS"] = set(["jpg", "jpeg", "png", "gif"])


# Connect to database and create database session
engine = create_engine("postgresql:///catalog")
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
Example #2
0

# Our stuff
app.config["LOG_LEVEL"] = log_level
app.config["FRIENDLY_NAME"] = friendly_name
app.config["SUPPORT_EMAIL"] = support_email
app.config["REMINDERS_EXPIRE"] = reminders_expire


# Google OAuth2 setup
secrets = None
with open("client_secrets.json") as f:
    secrets = json.load(f)["web"]

app.config["OAUTH2CALLBACK_PATH"] = "/oauth2callback"
app.config["GOOGLE_CLIENT_ID"] = secrets["client_id"]
app.config["GOOGLE_CLIENT_SECRET"] = secrets["client_secret"]
app.config["GOOGLE_LOGIN_REDIRECT_URI"] = "%s://%s%s" % (
    app.config["PREFERRED_URL_SCHEME"],
    app.config["SERVER_NAME"],
    app.config["OAUTH2CALLBACK_PATH"],
)
app.config["GOOGLE_LOGIN_DOMAIN"] = gafe_domain
app.config["GOOGLE_LOGIN_SCOPE"] = " ".join(
    [
        "email",
        "profile",
        "https://www.googleapis.com/auth/plus.login",
        "https://www.googleapis.com/auth/calendar",
        "https://www.googleapis.com/auth/gmail.modify",
    ]