Ejemplo n.º 1
0
def register_extensions(app: Flask):
    from models import ma
    from models import db, create_database
    db.init_app(app)
    ma.init_app(app)
    with app.app_context():
        create_database()
        db.create_all()
Ejemplo n.º 2
0
def create_app(DB_URL):
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = DB_URL
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SECRET_KEY'] = "secretkey"
    app.register_blueprint(api)
    db.init_app(app)

    db.create_all(app=app)
    ma.init_app(app)

    return app
Ejemplo n.º 3
0
def create_app():
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('IDB_DB_URI')
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.register_blueprint(blueprint)
    app.register_blueprint(articles_bp)
    app.register_blueprint(organizations_bp)
    app.register_blueprint(countries_bp)
    app.register_blueprint(search_bp)
    app.register_blueprint(wishlist_bp)
    db.init_app(app)
    ma.init_app(app)
    return app
def serializer_dactroy(app: Flask) -> Marshmallow:
    """Bootstrap Marshmallow for use with the flask-marshmallow extension.

    Args:
        app (Flask): The flask app to add this db engine to

    Returns:
        Marshmallow: Marshmallow
    """
    from models import ma

    ma.init_app(app)
    return ma
Ejemplo n.º 5
0
def create_app():
    #app = Flask(__name__, instance_relative_config=False)
    app.config.from_object(Config)
    db.init_app(app)
    ma.init_app(app)
    from routes import api_route
    app.register_blueprint(api_route, url_prefix='/api')

    with app.app_context():
        # Create tables for our models
        # from models.base import BaseModel
        db.create_all()
        return app
Ejemplo n.º 6
0
def create_app(config_filename="config"):
    print("sys path", sys.path)
    migrate = Migrate()
    app = Flask(__name__)
    app.config.from_object(config_filename)
    from app import api_bp
    app.register_blueprint(api_bp, url_prefix='/api')

    from models import db, ma
    db.init_app(app)
    migrate.init_app(app, db)
    ma.init_app(app)

    return app
Ejemplo n.º 7
0
def create_app():
    logger.debug('Making an app')
    app = Flask(__name__)
    app.config[
        'SQLALCHEMY_DATABASE_URI'] = 'postgresql://*****:*****@192.168.1.239:5432/melth_db'

    logger.debug('Initialisation of the DB')
    from models import db
    db.init_app(app)
    with app.app_context():
        db.create_all()

    logger.debug('Initialisation of the marshmallow')
    from models import ma
    ma.init_app(app)

    logger.debug('Initialisation of the api')
    from api import api
    api.init_app(app)

    return app
Ejemplo n.º 8
0
def create_app(test_config=None):
    # create and configure the app
    app = Flask(__name__)

    if test_config is None:
        # load the instance config, if it exists, when not testing
        app.config.from_pyfile('config.cfg', silent=True)
    else:
        # load the test config if passed in
        app.config.from_pyfile(test_config)

    # ensure the instance folder exists
    try:
        os.makedirs(app.instance_path)
    except OSError:
        pass

    api.init_app(app)
    db.init_app(app)
    ma.init_app(app)
    migrate.init_app(app, db)

    return app
Ejemplo n.º 9
0
from sqlalchemy import func

import json

#from db import db_init, db
from models import Users, Picture, Eventos, EventosSchema, db, ma

app = Flask(__name__)
app.config[
    'SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:palafox88@localhost/orm_exa'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['MAPBOX_MAP_ID'] = "example.abc123"
app.config['JWT_SECRET_KEY'] = 'secret'

db.init_app(app)
ma.init_app(app)

with app.app_context():
    db.create_all()

bcryp = Bcrypt(app)
jwt = JWTManager(app)
socketio = SocketIO(app)

evento_schema = EventosSchema()
eventos_schema = EventosSchema(many=True)


@app.route('/')
def index():
    return render_template('./AppPage.html')
Ejemplo n.º 10
0
# /home/tanuj/Work/wt/original/pinboard/venv/bin/pyhton
from flask import Flask, jsonify, request, session, redirect
from models import db, ma, Board, List, Card, BoardSchema, ListSchema, CardSchema, UserSchema
from flask_marshmallow import Marshmallow
# from sqlalchemy.ext.declarative import DeclarativeMeta
# from mongokit import Connection, Document
import json

import datetime
app = Flask(__name__)
app.config.from_pyfile('config.py')

db.init_app(app)
ma.init_app(app)

# connection = Connection(app.config['MONGODB_HOST'], app.config['MONGODB_PORT'])


board_schema = BoardSchema()
boards_schema = BoardSchema(many=True, only=('id', 'name'))
list_schema = ListSchema()
lists_schema = ListSchema(many=True)
card_schema = CardSchema()
cards_schema = CardSchema(many=True)
user_schema = UserSchema()

from pinboard_app.views import board,list,card,auth

app.secret_key = '>TJ\x88)X-F\x86\x04\x00\x8ff\xcb\x1c\xc5\x85R.\x9b.|\xdb\x97\xdb:\xa1\xd3E\x8a\xb4)\xd8\xa0\xa7G\xbb\x81\x0b-\xd1\x81\\\xd4\xd3\x0f`y\x82g'

# if __name__ == '__main__':
Ejemplo n.º 11
0
    settings = json.load(settings_file)

# Load application
application = Flask(__name__)
application.config['SQLALCHEMY_DATABASE_URI'] = settings["DATABASE_URI"]
application.config['LIBRARY_FOLDER'] = settings["LIBRARY_FOLDER"]
application.config['SECRET_KEY'] = settings["SECRET_KEY"]
application.config['LASTFM_API_KEY'] = settings["LASTFM_API_KEY"]
application.config['LASTFM_API_KEY_SECRET'] = settings["LASTFM_API_KEY_SECRET"]
# application.config['SESSION_TYPE'] = 'redis'
application.config['JSONIFY_PRETTYPRINT_REGULAR'] = False
application.debug = True

# Initialize SQLAlchemy, Marshmallow & Cache
db.init_app(application)
ma.init_app(application)
cache.init_app(application)
# session = Session()
# session.init_app(application)

# Initialize Celery
application.config['CELERY_BROKER_URL'] = 'redis://localhost:6379/0'
application.config['CELERY_BACKEND_URL'] = 'redis://localhost:6379/0'
celery = tasks.make_celery(application)

# Tell flask-restful this application is an API
api = Api(application, prefix='/api')

# Add Endpoints
from endpoints import *