示例#1
0
def create_app(config_filename):
    app = Flask(__name__)
    app.config.from_object(config_filename)

    from app import api_bp
    app.register_blueprint(api_bp, url_prefix='/api')

    return app
示例#2
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)
    
    bootstrap.init_app(app)
    mail.init_app(app)
    moment.init_app(app)
    db.init_app(app)
    pagedown.init_app(app)
    login_manager.init_app(app)
    
    if not app.debug and not app.testing and not app.config['SSL_DISABLE']:
        from flask_sslify import SSLify
        sslify = SSLify(app)
    
    #append route and customized error 
    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)
    
    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix="/auth")
    
    from .api_1_0 import api as api_1_0_blueprint
    app.register_blueprint(api_1_0_blueprint, url_prefix="/api/v1.0")
    
    return app
示例#3
0
from app import db
from flask import Flask
from flask import Blueprint
from app.models import *

from app.controllers.nologin import nologin
from app.controllers.projeto import projeto
from app.controllers.usuario import usuario
from app.controllers.repositorio import repositorio
from app.controllers.noticia import noticia
from app.controllers.tarefa import tarefa
from app.controllers.foto import foto
from app.controllers.arquivo import arquivo

app = Flask(__name__, template_folder='app/templates', static_folder='app/static')
app.register_blueprint(foto)
app.register_blueprint(nologin)
app.register_blueprint(projeto)
app.register_blueprint(arquivo)
app.register_blueprint(usuario)
app.register_blueprint(repositorio)
app.register_blueprint(noticia)
app.register_blueprint(tarefa)


uri= "postgresql://*****:*****@localhost:5432/CTA"
app.config['SQLALCHEMY_DATABASE_URI'] = uri
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

SECRET_KEY = os.urandom(32)
app.config['SECRET_KEY'] = SECRET_KEY
#!/usr/bin/env python
# encoding: utf-8
from app import create_app, register_blueprint

__author__ = "han"

app = create_app("../config/config.py")
register_blueprint(app)

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5000)
示例#5
0
文件: app.py 项目: xingkaixin/minicrm
CELERY_RESULT_BACKEND = "redis://localhost:6379"


app = Flask(__name__)
app.config.from_object(__name__)
db = SQLAlchemy(app)
Bootstrap(app)

# Initialize Celery
celery = Celery(app.name, broker=app.config["CELERY_BROKER_URL"])
celery.conf.update(app.config)


from view.main.main import main

app.register_blueprint(main)


@app.errorhandler(404)
def page_not_found(error):
    return render_template("error.html", error=error)


@app.errorhandler(401)
def no_permission(error):
    return render_template("error.html", error=error)


if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5000)
示例#6
0
import app as app
import onetimepass
import pyqrcode
from flask import Flask, render_template, redirect, url_for, flash, session, \
    abort
from flask_bootstrap import Bootstrap
from flask_login import LoginManager, UserMixin, login_user, logout_user, \
    current_user
from flask_sqlalchemy import SQLAlchemy
from flask_wtf import FlaskForm
from werkzeug.security import generate_password_hash, check_password_hash
from wtforms import StringField, PasswordField, SubmitField
from wtforms.validators import Length, EqualTo, DataRequired

app.register_blueprint(mainBlueprint, url_defaults='/<lang>')

# create application instance
app = Flask(__name__)
app.config.from_object('config')

# initialize extensions
bootstrap = Bootstrap(app)
db = SQLAlchemy(app)
lm = LoginManager(app)


class User(UserMixin, db.Model):
    """User model."""
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
示例#7
0
app.jinja_env.trim_blocks = True
app.jinja_env.lstrip_blocks = True

app.config.update(
    SECRET_KEY="verysecretkey",
    SQLALCHEMY_DATABASE_URI='sqlite:///muon_results.db',
    SQLALCHEMY_TRACK_MODIFICATIONS=False,
)

db.init_app(app)

Bootstrap(app)
admin = Admin(app, name="rsmdg", template_mode="bootstrap3")

# register blueprints
app.register_blueprint(detector_views)
app.register_blueprint(result_views)


@app.before_first_request
def before_first_request():
    db.create_all()
    db.session().commit()


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


@app.route("/log")
示例#8
0
app.config['SQLALCHEMY_DATABASE_URI'] = DB_URL

Session(app)

mail = Mail()
mail.init_app(app)

CORS(app,
     resources=r'*',
     headers=[
         'Content-Type', 'Authorization', 'Access-Control-Allow-Credentials',
         'Access-Control-Allow-Origin'
     ],
     supports_credentials=True)

app.register_blueprint(pg, url_prefix='/sync')

root_dir = os.path.dirname(os.path.abspath(__file__))
static_dir = os.path.join(root_dir, 'app/static')
app.config['UPLOADED_DEFAULTS_DEST'] = os.path.join(static_dir,
                                                    'uploads/defaults')
default_uploader = UploadSet('defaults', DEFAULTS)
configure_uploads(app, default_uploader)


@app.route('/')
def index():
    return 'It works'


@app.route('/<string:path>/<string:name>', methods=['GET', 'POST'])
示例#9
0



app = Flask(__name__)
app.config.from_object(__name__)
db = SQLAlchemy(app)
Bootstrap(app)

# Initialize Celery
celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL'])
celery.conf.update(app.config)



from view.main.main import main
app.register_blueprint(main)

@app.errorhandler(404)
def page_not_found(error):
    return render_template('error.html', error=error)


@app.errorhandler(401)
def no_permission(error):
    return render_template('error.html', error=error)


if __name__ == "__main__":
    app.run(host='0.0.0.0', port=5000)
示例#10
0
def blueprint_by_name(app, included_blueprints):
    for item in included_blueprints:
        module = import_module(item)
        app.register_blueprint(module.blueprint)
示例#11
0
import os

from flask_script import Manager

from app import blueprint
import app
from app.main import create_app

app = create_app(os.getenv('UPDRAFT_ENV') or 'dev')
app.register_blueprint(blueprint)

app.app_context().push()

manager = Manager(app)


@manager.command
def run():
    app.run()


if __name__ == '__main__':
    manager.run()
示例#12
0
import app
import flask
import flask_debugtoolbar

app = flask.Flask(__name__)
app.config.from_object('app.config')

db = flask.ext.sqlalchemy.SQLAlchemy(app)

mail = flask.ext.mail.Mail(app)

app.config['DEBUG_TB_TEMPLATE_EDITOR_ENABLED'] = True
app.config['DEBUG_TB_PROFILER_ENABLED'] = True
toolbar = flask_debugtoolbar.DebugToolbarExtension(app)

bcrypt = flask.ext.bcrypt.Bcrypt(app)

app.register_blueprint(app.views.user.userbp)

login_manager = flask.ext.login.LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'userbp.signin'


@login_manager.user_loader
def load_user(email):
    """
    DOCSTRING
    """
    return app.models.User.query.filter(app.models.User.email == email).first()
示例#13
0
    class ContextTask(TaskBase):
        abstract = True

        def __call__(self, *args, **kwargs):
            with app.app_context():
                return TaskBase.__call__(self, *args, **kwargs)

    celery.Task = ContextTask

    return celery


app = Flask(__name__)

# Configurations
app.config.from_object('config')

#celery
#celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL'])
#celery.conf.update(app.config)

#Bootstrap
bootstrap = Bootstrap(app)

#celery
celery = make_celery(app)
print("celery made")
#blueprints
from app.extractor.views import extractor
app.register_blueprint(extractor)