コード例 #1
0
 def setUpClass(cls):
     # Make sure database exists
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'
     app.config['DEBUG'] = False
     app.config['PROPAGATE_EXCEPTIONS'] = True
     with app.app_context():
         db.init_app(app)
コード例 #2
0
ファイル: __init__.py プロジェクト: Tranquilled/mstsversion2
def create_app():
    app = Flask(__name__)
    app.config.from_object('settings')

    # Creating the mail object to manage emails in flask
    mail.init_app(app)

    # initializing the database lazily
    db.init_app(app)

    # initializing gravatars
    gravatar = Gravatar(app,
                    size=100,
                    rating='g',
                    default='retro',
                    force_default=False,
                    force_lower=False,
                    use_ssl=False,
                    base_url=None)

    # registering the different modules in the application
    app.register_blueprint(blogs_blueprint,url_prefix='/blogs')
    app.register_blueprint(main_blueprint,url_prefix='/')
    app.register_blueprint(resources_blueprint,url_prefix='/resources')
    app.register_blueprint(users_blueprint,url_prefix='/users')

    # initializing the login manager lazily
    login_manager.init_app(app)

    return app
コード例 #3
0
 def setUp(self):
     app.config['SQLALCHEMY_DATABASE_URI'] = BaseTest.SQLALCHEMY_DATABASE_URI
     with app.app_context():
         db.init_app(app)
         db.create_all()
     self.app = app.test_client()
     self.app_context = app.app_context
コード例 #4
0
 def configure(self, binder):
     # We configure the DB here, explicitly, as Flask-SQLAlchemy requires
     # the DB to be configured before request handlers are called.
     with self.app.app_context():
         db.init_app(self.app)
         Base.metadata.create_all(db.engine)
     binder.bind(SQLAlchemy, to=db, scope=singleton)
コード例 #5
0
ファイル: app.py プロジェクト: StasEvseev/adminbuy
def init_app(application):
    from resources import api
    from assets import assets
    from applications.security.auth import login_manager
    from security import security

    application.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI
    application.config['SECURITY_TOKEN_AUTHENTICATION_HEADER'] = (
        "AUTHORIZATION")
    application.config['SECURITY_REMEMBER_SALT'] = "SALT123123123"
    application.config['SQLALCHEMY_ECHO'] = True
    application.config['SECRET_KEY'] = SECRET_KEY
    application.permanent_session_lifetime = timedelta(minutes=30)

    Triangle(application)
    assets.init_app(application)
    api.init_app(application)
    api.application = application
    db.init_app(application)
    login_manager.init_app(application)
    security.init_app(application)

    application.db = db
    application.api = api

    if IS_PROD:
        init_logging(application)

    return application
コード例 #6
0
ファイル: application.py プロジェクト: devjv/junction2015
    def __init__(self, *args, **kwargs):
        super(Application, self).__init__(__name__)
        self.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
        self.config['DEBUG'] = True

        # self.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
        self.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.db'
        db.init_app(self)
        self.register_blueprint(api)
        self.register_blueprint(user)
        self.register_blueprint(others)

        assets = Environment(self)
        assets.load_path = [
            os.path.join(os.path.dirname(__file__), 'bower_components'),
            os.path.join(os.path.dirname(__file__), 'static/js'),
            # os.path.join(os.path.dirname(__file__), 'bower_components'),
        ]
        assets.register(
            'js_all',
            Bundle(
                '**/**.min.js',
                'js/**.min.js',
                output='js_all.js'
            )
        )
コード例 #7
0
ファイル: __init__.py プロジェクト: uda/notifier
def create_app():
    app = Flask(__name__)
    app.config.from_object('_config')
    app.debug=True
    db.init_app(app)
    app.register_blueprint(notifier, url_prefix='')
    csrf.init_app(app)
    return app
コード例 #8
0
 def setUp(self):
     # Make sure database exists
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'
     with app.app_context():
         db.init_app(app)
         db.create_all()
     # Get a test client
     self.app = app.test_client()
     self.app_context = app.app_context
コード例 #9
0
ファイル: init.py プロジェクト: f-matos/kcsrv
def init(app):
    # --> Extension setup
    db.init_app(app)
    admin.init_app(app)

    modules["migrate"] = Migrate(app, db)

    modules["user_datastore"] = SQLAlchemyUserDatastore(db, User, Role)
    modules["security"] = Security(app, modules["user_datastore"], confirm_register_form=MyRegisterForm)

    # --> Register blueprints
    from modules.play.play import play

    app.register_blueprint(play, url_prefix='/play')

    from modules.api.core import api_core

    app.register_blueprint(api_core, url_prefix='/kcsapi')

    # Declare API v1 blueprints.
    from modules.api.v1.user import api_user
    from modules.api.v1.actions import api_actions
    app.register_blueprint(api_user, url_prefix='/kcsapi')
    app.register_blueprint(api_actions, url_prefix='/kcsapi')


    # Declare API v2 blueprints.
    from modules.api.v2.AdmiralAPI import AdmiralAPIv2
    from modules.api.v2.DockAPI import DockAPIv2
    app.register_blueprint(AdmiralAPIv2, url_prefix='/api/v2/admiral')
    app.register_blueprint(DockAPIv2, url_prefix='/api/v2/docks')

    from modules.resources import resources

    app.register_blueprint(resources, url_prefix='/kcs')

    # --> Base application routes
    @app.route('/')
    def index():
        return render_template('index.html')

    @app.route('/kcs/<path:path>')
    def kcs(path):
        return send_from_directory('kcs', path)

    # --> Signals
    @user_logged_in.connect_via(app)
    def u_logged_in(sender, user):
        """
        Regenerate the API token every login.
        """
        user.api_token = generate_api_token()
コード例 #10
0
ファイル: app.py プロジェクト: sbarratt/radius-collider
def create_app():
    """
    creats a flask app with configs and connect db
    """
    app = Flask(__name__)
    app.config.from_object('config')
    app.jinja_env.add_extension('jinja2.ext.loopcontrols')
    app.jinja_env.globals.update(get_score_color=util.get_score_color)
    app.jinja_env.globals.update(score_prediction=util.score_prediction)
    db.init_app(app)
    with app.app_context():
        db.create_all()
    return app
コード例 #11
0
ファイル: app.py プロジェクト: romantolkachyov/auth-test
def create_app(config='local'):
    app = Flask(__name__)
    app.config.from_object('project.settings.{}'.format(config))

    # db
    from db import db
    db.init_app(app)

    # auth blueprint
    from auth import blueprint as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix="/auth")

    return app
コード例 #12
0
ファイル: main.py プロジェクト: cnelsonsic/autotriops
def create_app(config_filename=None):
    app = Flask(__name__)
    app.config.from_pyfile(config_filename or 'config.py')

    from db import db
    db.init_app(app)
    db.app = app

    db.create_all()

    from views import dashboard
    app.register_blueprint(dashboard)

    return app
コード例 #13
0
ファイル: app.py プロジェクト: kraghupathi/web-application1
def create_app(config):
    # init our app
    app = Flask(__name__)
    app.secret_key = 'djfjsdkjXXS7979dfdfd'
    # load config values from the config file
    app.config.from_object(config)

    # init sqlalchemy db instance
    db.init_app(app)
    db.app = app
    # register blueprints
    app.register_blueprint(api)
    configure_logging(app)
    configure_errorhandlers(app)
    #  configure_cors(app)
    # all set; return app object
#   app.system = System()
    return app
コード例 #14
0
ファイル: __init__.py プロジェクト: ijabz/critiquebrainz
def create_app(config_object=None):
    app = Flask(__name__)
    app.config.from_object(config_object)

    from db import db as _db
    _db.init_app(app)

    # oauth init
    from oauth import oauth
    oauth.init_app(app)

    # register uuid converter
    from flask.ext.uuid import FlaskUUID
    FlaskUUID(app)

    # register error handlers
    import errors
    errors.init_error_handlers(app)

    # register loggers
    import loggers
    if app.debug is False:
        loggers.init_app(app)

    import login
    login.init_oauth_providers(app)

    # register blueprints
    from oauth.views import oauth_bp
    from login.views import login_bp
    from review.views import review_bp
    from user.views import user_bp
    from client.views import client_bp

    app.register_blueprint(oauth_bp, url_prefix='/oauth')
    app.register_blueprint(login_bp, url_prefix='/login')
    app.register_blueprint(review_bp, url_prefix='/review')
    app.register_blueprint(user_bp, url_prefix='/user')
    app.register_blueprint(client_bp, url_prefix='/client')

    return app
コード例 #15
0
ファイル: run.py プロジェクト: rafagonc/ReadingList-Server
def create_app(app):
    #config
    app.config.from_object(os.environ['APP_SETTINGS'])

    #models
    db.init_app(app)
    ma.init_app(app)

    with app.app_context():

        from models.book import Book
        from models.author import Author
        from models.rating import Rating
        from models.category import Category
        from models.user import User
        from models.log import ReadingLog
        db.create_all()
        db.session.commit()

        #create endpoints
        app.register_blueprint(endpoints)
コード例 #16
0
ファイル: webapp.py プロジェクト: hejin1026/extend104-web
def config_sqlalchemy(app):
    db.init_app(app)
    db.app = app    
コード例 #17
0
ファイル: main.py プロジェクト: htlcnn/anphode
def create_app():
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///./test.db'
    db.init_app(app)
    return app
コード例 #18
0
api.add_resource(Store, "/store/<string:name>")
api.add_resource(StoreList, "/stores")
api.add_resource(Item, "/item/<string:name>")
api.add_resource(ItemList, "/items")
api.add_resource(UserRegister, "/register")
api.add_resource(User, "/user/<int:user_id>")
api.add_resource(UserLogin, "/login")
api.add_resource(TokenRefresh, "/refresh")
api.add_resource(UserLogout, "/logout")
api.add_resource(Order, '/order')
api.add_resource(OrderList, '/orders')
api.add_resource(OrderListForUser, '/order/user/<int:user_id>')

api.add_resource(Cart, '/cart/<int:user_id>', '/cart/add')
api.add_resource(CartList, '/carts')
api.add_resource(OrderItemsList, '/order/items/<int:order_id>')
api.add_resource(MakePaymentForOrder, '/makePayment/<int:order_id>')

if __name__ == "__main__":
    db.init_app(app)
    ma.init_app(app)

    if app.config['DEBUG']:

        @app.before_first_request
        def create_tables():
            db.create_all()

    app.run(port=5000, debug=True)
コード例 #19
0
ファイル: app.py プロジェクト: b9007/Python
app.config['DEBUG'] = True

app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', 'sqlite:///data.db')
SQLALCHEMY_TRACK_MODIFICATIONS = False
app.secret_key = '12345'
api = Api(app)

jwt = JWT(app, authenticate, identity) # /auth

api.add_resource(Store, '/store/<string:name>')
api.add_resource(Item, '/item/<string:name>')
api.add_resource(ItemList, '/items')
api.add_resource(StoreList, '/stores')
api.add_resource(UserRegister, '/register')

@app.errorhandler(JWTError)
def auth_error_handler(err):
    return jsonify({'message': 'Could not authorize. Did you include a valid Authorization Header?'}), 401

if __name__ == '__main__':
    from db import db

    db.init_app(app)

    if app.config['DEBUG']:
        @app.before_first_request
        def create_tables():
            db.create_all()

    app.run(port=5000)
コード例 #20
0
 def setUpClass(cls):
     app.config['SQLALCHEMY_DATABASE_URI'] = BaseTest.SQLALCHEMY_DATABASE_URI
     app.config['DEBUG'] = False
     with app.app_context():
         db.init_app(app)
コード例 #21
0
ファイル: base_test.py プロジェクト: b9007/Python
 def setUpClass(cls):
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'
     with app.app_context():
         db.init_app(app)
コード例 #22
0
ファイル: app.py プロジェクト: wrunion/dwellinglybackend
from resources.user import UserRegister, User, UserLogin
from resources.property import Properties, Property
from db import db

app = Flask(__name__)
#config DataBase
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///data.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['PROPAGATE_EXCEPTIONS'] = True
app.secret_key = 'dwellingly'  #Replace with Random Hash
#allow cross-origin (CORS)
CORS(app)

api = Api(app)

db.init_app(app)  #need to solve this


@app.before_first_request
def create_tables():
    db.create_all()


jwt = JWTManager(app)  # /authorization


@jwt.user_claims_loader
#check if user role == admin
def role_loader(identity):  #idenity = user.id in JWT
    user = UserModel.find_by_id(identity)
    if user.role == 'admin':