Beispiel #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"]}
}
Beispiel #2
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"},
    "google": {"id": "google application ID", "secret": "google 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)
    email = db.Column(db.String(64), nullable=True)


@lm.user_loader
def load_user(id):
    return User.query.get(int(id))
Beispiel #3
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