Example #1
0
"""Head application module."""
import logging
import os
from datetime import timedelta

from flask import Flask
from flask.ext.triangle import Triangle

from ecomap.config import Config
from ecomap.utils import get_logger

_CONFIG = Config().get_config()

TEMPLATE_FOLDER = os.path.join(os.environ["PRODROOT"], "www/templates/")
app = Flask(__name__, template_folder=TEMPLATE_FOLDER)
Triangle(app)

get_logger()
logger = logging.getLogger("flask_app")
app.config["SECRET_KEY"] = "a7c268ab01141868811c070274413ea3c588733241659fcb"
app.config["REMEMBER_COOKIE_DURATION"] = timedelta(days=14)  # user time lib
app.config["OAUTH_CREDENTIALS"] = {
    "facebook": {"id": _CONFIG["oauth.facebook_id"], "secret": _CONFIG["oauth.facebook_secret"]}
}
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager
from flask_wtf.csrf import CsrfProtect

""" app.py - Setup and configuration of the flask application. """

app = Flask(__name__)
app.config["DEBUG"] = False
app.config["SQLALCHEMY_DATABASE_URI"] = "postgresql:///catalog"
app.config["OAUTH_CREDENTIALS"] = {
    "google": {
        "id": "584583057556-nmte80jga2pqjfet0ktp7e7qk5n7rja2.apps.googleusercontent.com",
        "secret": "pumSChkenM46Wh2iKZEDMmgc",
    }
}
app.config["SECRET_KEY"] = "THISISAREALLYBADSECRETKEYDONTUSEITINREALLIFE"
app.config["WTF_CSRF_SECRET_KEY"] = "THISISAREALLYBADSECRETKEYDONTUSEITINREALLIFE"
login_manager = LoginManager()
login_manager.session_protection = "basic"
db = SQLAlchemy(app)
CsrfProtect(app)
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.
    """
Example #4
0
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"] = {
    "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:
        user = session.query(User).filter_by(username=username_or_token).first()
        if not user or not user.verify_password(password):
            return False
Example #5
0
from datetime import timedelta, datetime
from functools import update_wrapper

from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager, UserMixin, logout_user, current_user, login_user
from oauth import OAuthSignIn
import ast
from functools import wraps

# flask app
current_version = "08"
app = Flask(__name__)
app.config["SECRET_KEY"] = "F!12Z@r47j\3yXm J xu&R~>X@H!j<<mM]Lwf/,?KXTxQ!"
app.config["MONGO_URI"] = "127.0.0.1:27017"
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///db.sqlite"
app.config["OAUTH_CREDENTIALS"] = {"facebook": {"id": "940836925972002", "secret": "4c954cbadb8c15ea65c49585f2c794c5"}}

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


# Facebook login stuff
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)
    data = db.Column(db.String(64), nullable=False)
    email = db.Column(db.String(64), nullable=False)
Example #6
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": "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)
    email = db.Column(db.String(64), nullable=True)


@lm.user_loader
def load_user(id):
    return User.query.get(int(id))
Example #7
0
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager
from flask.ext.bootstrap import Bootstrap
from flask.ext.moment import Moment
from instance.config import APP_ID, APP_SECRET
from .momentjs import momentjs

app = Flask(__name__, instance_relative_config=True)
app.config.from_pyfile("config.py")
app.config["OAUTH_CREDENTIALS"] = {"facebook": {"id": APP_ID, "secret": APP_SECRET}}
app.jinja_env.globals["momentjs"] = momentjs
db = SQLAlchemy(app)
lm = LoginManager(app)
lm.login_view = "login"
bootstrap = Bootstrap(app)
moment = Moment(app)
from app import views, models
Example #8
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": "145224459145814", "secret": "a7bfc0602ae655274952f7d33af7f8dc"},
    "twitter": {"id": "3RzWQclolxWZIMq5LJqzRZPTl", "secret": "m9TEd58DSEtRrZHpz2EjrV9AhsBRxKMo8m3kuIZj3zLwzwIimt"},
}

db = SQLAlchemy(app)
lm = LoginManager(app)
lm.login_view = "api"


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)


@lm.user_loader
def load_user(id):
    return User.query.get(int(id))

Example #9
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
def load_user(id):
    return User.query.get(int(id))


@app.route("/")
def index():
Example #10
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 #11
0
#!flask/bin/python
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 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/
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)
    dbC = MongoClient("localhost", 27017)
else:
    server = "http://52.37.251.245/"
    # server = "http://ec2-52-37-251-245.us-west-2.compute.amazonaws.com/"
    # server = "http://linkcuration.ddns.net/"
    dbC = MongoClient("localhost", 12345)

# 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 #13
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
def load_user(id):
    return User.query.get(int(id))

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"] = {
    "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)
    email = db.Column(db.String(64), nullable=True)


@lm.user_loader
def load_user(id):
    return User.query.get(int(id))
Example #15
0
from flask import Flask, flash, 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"] = "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"
    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
def load_user(id):
Example #16
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 #17
0
from config import PHOTO_BASE_DIR, QQ_APP_ID, QQ_APP_KEY
from flask import Flask
from flask.ext.cache import Cache
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,
    request_token_params={"scope": "get_user_info"},
    access_token_url="/oauth2.0/token",
from flask import Flask, jsonify, request, url_for, make_response, g, render_template, Response, abort, redirect, flash
from flask.ext.httpauth import HTTPBasicAuth
from flask.ext.sqlalchemy import SQLAlchemy
from datetime import datetime
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():
    return make_response(jsonify({"error": "Unauthorized access"}), 401)

Example #19
0
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
    )
    mail_handler.setLevel(logging.ERROR)
    app.logger.addHandler(mail_handler)
Example #20
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 #21
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)


class AsyncOperationStatus(db.Model):
    __tablename__ = "async_operation_status"
Example #22
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 #23
0
from database.database_insert import insert_user, insert_social_user
from database.database_query import query_user, query_social_user, number_of_users

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 #24
0
import os
from datetime import datetime
import time
import json

app = Flask(__name__)

UPLOAD_FOLDER = "/static/posts/uploads"
ALLOWED_EXTENSIONS = set(["jpg", "png", "jpeg"])

app.config["SECRET_KEY"] = os.urandom(24)
app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///db.sqlite"

app.config["OAUTH_CREDENTIALS"] = {
    "facebook": {"id": "232991410370871", "secret": "ca0f688420f86264b9003708c48050db"},
    "twitter": {"id": "VJnPtET7hBLVfJ4WQl4ImaBTa", "secret": "sgQxTgzyOPqdS2t7g9iH79vhgYfmyZGTjIS2ujmzk1W2hn6Y7S"},
}

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


class User(UserMixin, db.Model):
    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)
    name = db.Column(db.String(64), nullable=False)
    email = db.Column(db.String(64), nullable=True)
    picture = db.Column(db.Text, nullable=True)
    posts = db.relationship("Post", backref="user_id", lazy="dynamic")
# oauthConfig.py is NOT COMMITTED to the github repo.

import os

# These you get from the developer pages of Facebook, Twitter and Google.
# 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