Exemplo n.º 1
0
def create_app(config_file):
    app = Flask(__name__)
    app.config.from_pyfile(config_file)

    from models import db, bcrypt, oid, login_manager, csrf

    db.init_app(app)  # DB initialisation
    bcrypt.init_app(app)  # Bcrypt hashing initialisation
    oid.init_app(app)  # OpenID initialisation
    login_manager.init_app(app)  # flask_login initialisation
    csrf.init_app(app)  # CSRF Protection initialisation for all the app
    # oauth.init_app(app)

    # from app.views.about import about
    # from app.views.admin import admin
    from app.views.feed import feed
    # from app.profile.views import profile_b
    from app.views.signing import signing
    from app.views.post import post
    #from app.publications.views import publication_b

    # Registration of the blueprints
    # app.register_blueprint(about_b, url_prefixe="/about/")
    # app.register_blueprint(admin_b, url_prefixe="/admin/")
    app.register_blueprint(
        feed)  # On arrive directement sur le feed qd on lance l'appli
    # app.register_blueprint(profile_b, url_prefixe="/profile/")
    app.register_blueprint(signing)
    app.register_blueprint(post)
    # app.register_blueprint(publication_b, url_prefixe="/publication/")
    # app.register_blueprint(layout_b)

    return app
Exemplo n.º 2
0
def create_app():
    #app = Flask(__name__, static_folder="../frontend", template_folder="../frontend/src")
    app = Flask(__name__)
    app.config.from_object(BaseConfig)
    db.init_app(app)
    bcrypt.init_app(app)
    register_blueprint(app)
    return app
Exemplo n.º 3
0
def create_app(env_name):
    # app initiliazation
    app.config.from_object(app_config[env_name])
    bcrypt.init_app(app)
    db.init_app(app)
    api.add_resource(UserController, '/api/v1/users', '/api/v1/users/')

    @app.route('/', methods=['GET'])
    def index():
        return {'message': 'welcome to karya'}

    return app
Exemplo n.º 4
0
def create_app(env_name):
    app = Flask(__name__)
    app.config.from_object(app_config[env_name])

    # initializing bcrypt
    bcrypt.init_app(app)

    db.init_app(app)
    app.register_blueprint(user_blueprint, url_prefix='/api/v1/users')
    app.register_blueprint(blogpost_blueprint, url_prefix='/api/v1/blogposts')

    return app
Exemplo n.º 5
0
def initalize_app():
    app = Flask(__name__)
    app.config.update(
        SQLALCHEMY_DATABASE_URI=os.environ.get('DATABASE_URL', 'sqlite:///database'),
        SQLALCHEMY_ECHO=True,
        DEBUG=True if os.environ.get('DEBUG', 'false') == 'true' else False,
        SECRET_KEY="top secret okay"
    )
    bcrypt.init_app(app)
    db.init_app(app)
    Gravatar(app, size=100, rating='g', default='retro', force_default=False, force_lower=False)
    return app
Exemplo n.º 6
0
def create_app(config=None, env=None):
    """
    Flask application factory. See:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Arguments:
        config: python path to config object
        env: Current environment. Eg prod, dev, stage
    """

    app = Flask(__name__)

    # Load config object
    if env is None:
        env = os.environ.get('REGO_ENV', 'prod')
    if config is None:
        config = 'rego.settings.%sConfig' % env.capitalize()

    app.config.from_object(config)

    # Optionally, load extra config from file
    if os.environ.get('DASH_SETTINGS', None):
        app.config.from_envvar('DASH_SETTINGS')

    # Set up plugins
    db.init_app(app)
    migrate.init_app(app, db)
    bcrypt.init_app(app)

    if app.debug:
        from flask_debugtoolbar import DebugToolbarExtension
        DebugToolbarExtension(app)

    # register blueprints
    from views.admin import admin
    from views.login import login, login_manager
    from views.main import main
    login_manager.init_app(app)
    app.register_blueprint(admin, url_prefix='/admin')
    app.register_blueprint(login)
    app.register_blueprint(main)

    from views.api import api
    api.init_app(app)

    # Load extra jinja stuff
    app.jinja_env.add_extension('jinja2.ext.do')

    return app
Exemplo n.º 7
0
def create_app(**config):
    app = Flask(__name__)

    app.url_map.converters['objectid'] = ObjectIDConverter
    init_errorhandler(app)

    init_config(app)
    app.config.from_mapping(config)

    db.init_app(app)
    bcrypt.init_app(app)

    register_blueprints(app)

    return app
Exemplo n.º 8
0
def create_app(env_name):
    app=Flask(__name__)
    app.config.from_object(app_config[env_name])
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' 
    bcrypt.init_app(app)
    db.init_app(app)
    api=Api(app)


    @api.route("/hello")
    class Helloworld(Resource):
        def get(self):
            return jsonify("hello world")

    return app
Exemplo n.º 9
0
def create_app():
    app = Flask(__name__)

    file_handler = StreamHandler()
    app.logger.setLevel(logging.DEBUG)
    app.logger.addHandler(file_handler)

    app.config.from_object('dd.config')
    for k in app.config:
        v = os.environ.get(k, None)
        if v is not None:
            app.config[k] = v
    app.config['SQLALCHEMY_DATABASE_URI'] = app.config['DATABASE_URL']

    assets.init_app(app)
    manager.init_app(app)
    db.init_app(app)
    bcrypt.init_app(app)

    app.register_blueprint(admin, url_prefix='/admin')
    app.register_blueprint(public)
    return app
Exemplo n.º 10
0
def create_app(env_name):
  """
  Create app
  """
  
  # app initiliazation
  app = Flask(__name__)

  app.config.from_object(app_config[env_name])

  # initializing bcrypt and db
  bcrypt.init_app(app)
  db.init_app(app)

  app.register_blueprint(workflow_blueprint, url_prefix='/api/v1/')

  @app.route('/', methods=['GET'])
  def index():
    """
    example endpoint
    """
    return 'Congratulations! Your part 2 endpoint is working'

  return app
Exemplo n.º 11
0
# get database info from secret config.py file, NOT pushed to github or heroku
app.config.from_object(os.environ['APP_SETTINGS'])
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

# make sure we got the database URL
if app.config['SQLALCHEMY_DATABASE_URI'] == None:
    print "Need database config"
    sys.exit(1)

############ Do the configuration for the database #############
from models import db
db.init_app(app)

############ Do the configuration for bycrpt #############
from models import bcrypt
bcrypt.init_app(app)

############ Do the configuration for the S3 storage bucket #############
from photo import store
store.init_app(app)

############ Do the configuration for email #############
from mail import mail
mail.init_app(app)

############ Do the configuration for the CDN Amazon Cloud Storage #############
from flask_cdn import CDN

if app.config['IS_CDN_ENABLED'] == 'True':
    cdn = CDN()
    cdn.init_app(app)
Exemplo n.º 12
0
import flask.ext.login as flask_login
import os

from flask import Flask, render_template, abort, request, jsonify, redirect, url_for, flash
from models import db, bcrypt, User
from forms import LoginForm, RegistrationForm
from flask_login import login_user, logout_user, login_required


app = Flask(__name__)
app.config.from_object(os.environ['APP_SETTINGS'])

bcrypt.init_app(app)

db.init_app(app)

login_manager = flask_login.LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'login'

@login_manager.user_loader
def user_loader(email):
    return User.get_by_email(email)

@app.route('/')
def index():
	form = LoginForm()
	if form.validate_on_submit():
		login_user(form.user)
		next = request.args.get('next')
		return redirect(next or url_for('index'))