예제 #1
0
파일: app.py 프로젝트: AJRenold/futurepress
def create_app(config_object):

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

    for blueprint in futurepress_blueprints:
        app.register_blueprint(blueprint)

    db = SQLAlchemy()
    db.init_app(app)

    stormpath_manager = StormpathManager(app)
    stormpath_manager.login_view = 'auth_routes.login'

    @app.context_processor
    def inject_appuser():
        if user.is_authenticated():
            user_id = user.get_id()
            app_user = AppUser.query.get(stormpathUserHash(user_id))
            return dict(app_user=app_user)
        return dict(app_user=None)

    @app.route('/')
    def index():
        return render_template('index.html')

    @app.route('/copyright')
    def copyright():
        return render_template('copyright.html')

    @app.route('/makers')
    def makers():
        """ """
        if user.is_authenticated():
            return render_template('makers.html')

        return render_template('makers.html')

    @app.route('/readers')
    def readers():
        if user.is_authenticated():
            return render_template('readers.html')

        return render_template('readers.html')

    return app
예제 #2
0
    url = urlparse.urlparse("redis://*****:*****@dab.redistogo.com:9082/")
    redis = redis.Redis(host=url.hostname, port=url.port, db=0, password=url.password)

app.config['STORMPATH_ENABLE_USERNAME'] = True
app.config['STORMPATH_REQUIRE_USERNAME'] = True
app.config['STORMPATH_ENABLE_FORGOT_PASSWORD'] = True
app.config['STORMPATH_REGISTRATION_TEMPLATE'] = 'register.html'
app.config['STORMPATH_LOGIN_TEMPLATE'] = 'login.html'
app.config['STORMPATH_FORGOT_PASSWORD_TEMPLATE'] = 'forgot.html'
app.config['STORMPATH_FORGOT_PASSWORD_EMAIL_SENT_TEMPLATE'] = 'forgot_email_sent.html'
app.config['STORMPATH_FORGOT_PASSWORD_CHANGE_TEMPLATE'] = 'forgot_change.html'
app.config['STORMPATH_FORGOT_PASSWORD_COMPLETE_TEMPLATE'] = 'forgot_complete.html'

stormpath_manager = StormpathManager(app)
stormpath_manager.login_view = 'login'

#Store messages in redis database.
def logMessage(number, message):
    try:
        redis.rpush(user.username + "_Messages", number + " " + message)
        print("LOGGED")
    except Exception as e:
        print(e.message)

def generateMessage():
    """Generate a random adjective and noun

    Returns:
        tuple - (string, string) - (adjective, noun)
    """
예제 #3
0
from os import environ

from flask import Flask, redirect, render_template, request, url_for
from flask.ext.stormpath import StormpathManager, User, login_required, login_user, logout_user, user
from stormpath.error import Error as StormpathError

app = Flask(__name__)
app.debug = True
app.config['SECRET_KEY'] = 'ilovecookies'
app.config['STORMPATH_API_KEY_ID'] = environ.get('STORMPATH_API_KEY_ID')
app.config['STORMPATH_API_KEY_SECRET'] = environ.get(
    'STORMPATH_API_KEY_SECRET')
app.config['STORMPATH_APPLICATION'] = environ.get('STORMPATH_APPLICATION')

stormpath_manager = StormpathManager(app)
stormpath_manager.login_view = '.login'


##### Website
@app.route('/')
def index():
    """Basic home page."""
    return render_template('index.html')


@app.route('/register', methods=['GET', 'POST'])
def register():
    """
    This view allows a user to register for the site.

    This will create a new User in Stormpath, and then log the user into their