Beispiel #1
0
def initialize_app(flask_app):
    blueprint = Blueprint('api', __name__, url_prefix='/api')
    api.init_app(blueprint)
    flask_app.register_blueprint(blueprint)
    api.add_namespace(user_namespace)
    api.add_namespace(movies_namespace)
    api.add_namespace(bookings_namespace)
Beispiel #2
0
def initialize_app(flask_app):
    configure_app(flask_app)
    blueprint = Blueprint('api', __name__, url_prefix='/api')
    api.init_app(blueprint)
    api.add_namespace(user_posts_namespace)
    flask_app.register_blueprint(blueprint)
    db.init_app(flask_app)
Beispiel #3
0
def init_app(app, config_type):
    configure_app(app, config_type)
    app.url_map.strict_slashes = False
    db.init_app(app)

    api.init_app(app)
    api.add_namespace(ns)

    if config_type == "testing":
        with app.app_context():
            db.drop_all()
            db.create_all()
def initialize_app(app):

    app.config["RESTPLUS_VALIDATE"] = True
    app.config['ERROR_404_HELP'] = False

    config_db(app)
    blueprint = Blueprint('api', __name__)

    api.init_app(blueprint)
    app.register_blueprint(blueprint)

    api.add_namespace(ns_default)
    api.add_namespace(ns_category)
Beispiel #5
0
def create_app():
    app = Flask(__name__)
    app.config.from_object(Config)
    blueprint = Blueprint('api', __name__, url_prefix='/api')
    api.init_app(blueprint)

    # Iterates over the namespaces list and adds them to the API
    for namespace in namespaces:
        api.add_namespace(namespace)

    app.register_blueprint(blueprint)
    db.init_app(app)

    return app
Beispiel #6
0
def create_app(app=app, db_url=os.environ.get('DATABASE_DEFAULT_URL')):
    app.config['RESTPLUS_VALIDATE'] = True
    app.config['ERROR_404_HELP'] = False
    app.url_map.strict_slashes = False
    config_db(app, db_url)

    blueprint = Blueprint('api', __name__)
    api.init_app(blueprint)
    api.security = 'oauth2'
    api.authorizations = authorizations
    api.add_namespace(ns_book)
    api.add_namespace(ns_client)
    app.register_blueprint(blueprint)

    return app
Beispiel #7
0
from resources import app, celery
from restplus import api
from flask import Flask, Blueprint

blueprint = Blueprint('api', __name__, url_prefix='/api')

api.init_app(blueprint,
             version='0.1',
             title='Pokemon Battle Valdivia',
             description='Pokemon league api')

app.register_blueprint(blueprint)

if __name__ == "__main__":
    app.run(debug=True, port=8010)
Beispiel #8
0
from flask import (Blueprint, request, jsonify)
from flask_restplus import Resource

from log import log
from restplus import api
from serializers import simulation_serializer

simulation_blueprint = Blueprint('simulation', __name__)

api.init_app(simulation_blueprint)


@api.route('/api/v1/simulation')
class SimulationCollection(Resource):
    @api.expect(simulation_serializer)
    def post(self):
        log.info('API call simulation')
        data = request.get_json(force=True)
        loan_value = float(data['loan_value'])
        tax = float(data['tax'])
        installments = int(data['installments'])

        amount = loan_value * ((1 + tax / 100)**installments)
        fees = amount - loan_value

        return jsonify(
            status=True,
            message=
            "Loan value: {}\nFees (Tax: {}): {}\nAmount after ({} months): {}".
            format(str("R$ %.2f" % loan_value), tax, str("R$ %.2f" % fees),
                   installments, str("R$ %.2f" % amount)))
Beispiel #9
0
app = Flask(__name__, instance_path=instance_path)
app.json_encoder = DynamicJSONEncoder
app.config['PROPAGATE_EXCEPTIONS'] = True
app.config['RESTPLUS_JSON'] = {
    'cls': DynamicJSONEncoder,
}

if "DEBUG" in os.environ:
    app.debug = os.environ['DEBUG'].lower() == "true"
else:
    app.debug = False
Bootstrap(app)
app.jinja_env.globals['url_for_other_page'] = url_for_other_page

blueprint = Blueprint('api', __name__, url_prefix='/api')
api.init_app(blueprint)


def get_page():
    """Get 'page' parameter."""
    page_str = request.args.get('page', '1')
    try:
        page = int(page_str)
    except ValueError:
        page = 1
    return page


# The '/' page is accessible to anyone
@app.route('/')
def home():
Beispiel #10
0
    Blueprint, request, jsonify
)
from flask_restplus import Resource
from bson import json_util
import json

from flask_jwt_extended import verify_jwt_in_request, get_jwt_identity

from models import Taxas, Clientes
from log import log
from restplus import api
from serializers import tax_serializer, loan_serializer

tax_blueprint = Blueprint('tax', __name__)

api.init_app(tax_blueprint)

@api.route('/api/v1/tax')
class TaxCollection(Resource):

    def get(self):        
        log.info('API call get tax')
       
        _tax = Taxas.objects.all()
        
        data = json.loads( _tax.to_json())

        return jsonify(data)

@api.route('/api/v1/loan')
class LoanCollection(Resource):
Beispiel #11
0
    os.environ.get('OPENSHIFT_PYTHON_DIR',
                   os.path.dirname(os.path.dirname(
                       os.path.abspath(__file__)))), 'instance')
app = Flask(__name__, instance_path=instance_path)
app.json_encoder = DynamicJSONEncoder
app.config['PROPAGATE_EXCEPTIONS'] = True
app.config['RESTPLUS_JSON'] = {
    'cls': DynamicJSONEncoder,
}

app.debug = strtobool(os.environ.get('DEBUG', 'false'))
Bootstrap(app)
app.jinja_env.globals['url_for_other_page'] = url_for_other_page

blueprint = Blueprint('api', __name__, url_prefix='/api')
api.init_app(blueprint)


def get_page():
    """Get 'page' parameter."""
    page_str = request.args.get('page', '1')
    try:
        page = int(page_str)
    except ValueError:
        page = 1
    return page


# The '/' page is accessible to anyone
@app.route('/')
def home():
Beispiel #12
0
def init_app(flask_app):
    blueprint = Blueprint('api', __name__, url_prefix='/api')
    api.init_app(blueprint)
    api.add_namespace(test_namespace)
    api.add_namespace(document_namespace)
    flask_app.register_blueprint(blueprint)
Beispiel #13
0
from flask_jwt_extended import create_access_token, create_refresh_token
import datetime
#from flask_mongoengine import Pagination

from models import Clientes
from log import log
from restplus import api
from serializers import customer_serializer

#async
import asyncio
import threading

customer_blueprint = Blueprint('customer', __name__)

api.init_app(customer_blueprint)


@api.route('/api/v1/login/async')
class CustomerAsyncCollection(Resource):
    def get(self):
        return jsonify(status=True, message="It's alive!")

    #@api.response(201, 'Login successfully.')
    @api.expect(customer_serializer)
    def post(self):
        log.info(f"Function: {threading.current_thread().name}")
        data = request.get_json(force=True)

        loop = asyncio.get_event_loop()
        result = loop.run_until_complete(getLoginAsync(data))