def run(): # import namespaces from app.api.visitor.endpoints.visitor import ns as visitor_namespace from app.api.behavee.endpoints.behavee import ns as behavee_namespace blueprint = Blueprint('api', __name__) api.init_app(blueprint) # add API namespaces api.add_namespace(visitor_namespace) api.add_namespace(behavee_namespace) app.register_blueprint(blueprint, url_prefix=app.config['FLASK_API_URL_PREFIX']) # Here we patch the application from werkzeug.contrib.fixers import ProxyFix app.wsgi_app = ProxyFix(app.wsgi_app) db = SQLAlchemy(app) db.init_app(app) host = app.config['FLASK_SERVER_HOST'] port = app.config['FLASK_SERVER_PORT'] debug = app.config['FLASK_DEBUG'] app.run(host=host, port=port, debug=debug)
def initialize_app(flask_app): configure_app(flask_app) blueprint = Blueprint('api', __name__, url_prefix='/api') api.init_app(blueprint) api.add_namespace(tests_namespace) # add more namespaces here flask_app.register_blueprint(blueprint)
def initialize_app(flask_app): configure_app(flask_app) blueprint = Blueprint('api', __name__, url_prefix='/api') api.init_app(blueprint) api.add_namespace(blog_posts_namespace) api.add_namespace(blog_categories_namespace) flask_app.register_blueprint(blueprint) db.init_app(flask_app)
def initialize_app(app): log.info("Test log") configure_app(app) blueprint = Blueprint('api', __name__, url_prefix='/api') api.init_app(blueprint) api.add_namespace(interactions) api.add_namespace(metadata) app.register_blueprint(blueprint) db.init_app(app) log.info("finished initialize")
def initialize_app(flask_app): # register blueprint blueprint = Blueprint("api", __name__, url_prefix="/api") api.init_app(blueprint) flask_app.register_blueprint(blueprint) # set custom encoder flask_app.json_encoder = CustomJSONEncoder # add namespaces api.add_namespace(ns_timeseries)
def initialize_app(flask_app): configure_app(flask_app) blueprint = Blueprint('api', __name__, url_prefix='/api') api.init_app(blueprint) # api.add_namespace(ip_vpn_voice_namespace) flask_app.register_blueprint(blueprint) db.init_app(flask_app) @app.route('/') def redirecttoapi(): return redirect('/api', 302)
def create_app(config=None): app = Flask(__name__, instance_relative_config=True) app.config.from_mapping( SECRET_KEY='dev', DATABASE=os.path.join(app.instance_path, 'app.sqlite'), ) # SQLALCHEMY app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///../instance/app.sqlite' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True app.config['SQLALCHEMY_ECHO'] = True # Celery configuration app.config['CELERY_BROKER_URL'] = "sqla+sqlite:///instance/app.sqlite" app.config['RESULT_BACKEND'] = "db+sqlite:///instance/app.sqlite" # Flask-Mail configuration # app.config['MAIL_SERVER'] = 'smtp.events.com' # app.config['MAIL_PORT'] = 587 # app.config['MAIL_USE_TLS'] = True app.config['MAIL_USERNAME'] = os.environ.get('MAIL_USERNAME') app.config['MAIL_PASSWORD'] = os.environ.get('MAIL_PASSWORD') app.config['MAIL_DEFAULT_SENDER'] = '*****@*****.**' # ensure the instance folder exists try: os.makedirs(app.instance_path) except OSError: pass init_celery(app) db.init_app(app) mail.init_app(app) api_blueprint = Blueprint("api", __name__, url_prefix="/api/v1") api.init_app(api_blueprint) api.add_namespace(users_namespace) api.add_namespace(events_namespace) api.add_namespace(signups_namespace) app.register_blueprint(api_blueprint) return app
def create_app(): """ Initializes app :return: app: Flask app """ app = Flask(__name__) app.config.update(DATA_PATH=DATA_PATH) blueprint = Blueprint('api', __name__, url_prefix='/api') api.init_app(blueprint) api.add_namespace(ns_sites) api.add_namespace(ns_monitoring) app.register_blueprint(blueprint) app.add_url_rule('/', view_func=ShowDashboard.as_view('show_dashboard')) socketio = SocketIO(app, message_queue=CELERY_BROKER) @socketio.on('connection', namespace='/test') def confirmation_message(message): emit('confirmation', {'connection_confirmation': message['Connected']}) return app
def create_app(): init_logger(__name__) app = Flask(__name__) app.config['BUNDLE_ERRORS'] = True if app.config["DEBUG"]: app.config.from_pyfile("./configs/dev.py") else: app.config.from_pyfile("./configs/dev.py") # to avoid Runtime error with app.app_context(): init_db() blueprint = Blueprint("api", __name__, url_prefix="/api") api.init_app(blueprint) api.add_namespace(ns_auth) api.add_namespace(ns_users) app.register_blueprint(blueprint) return app
def initialize_app(app): blueprint = Blueprint('api', __name__, url_prefix='/v1') db.init_app(app) api.init_app(blueprint) api.add_namespace(customer_login_ns) api.add_namespace(customer_signup_ns) api.add_namespace(customer_updation_ns) api.add_namespace(seller_signup_ns) api.add_namespace(seller_login_ns) api.add_namespace(add_item_ns) api.add_namespace(get_item_ns) api.add_namespace(add_cart_ns) api.add_namespace(get_cart_ns) api.add_namespace(get_order_ns) api.add_namespace(create_order_ns) api.add_namespace(add_deal_ns) api.add_namespace(get_deal_ns) app.register_blueprint(blueprint)
import os from flask import Flask, Blueprint from app.api.restplus import api from app.api.endpoints.message import ns as REST_backend_namespace from app.api.endpoints.message import mongo app = Flask(__name__) app.config['MONGO_URI'] = os.environ.get('DB') app.config['RESTPLUS_MASK_SWAGGER'] = False blueprint = Blueprint('api', __name__, url_prefix='/api') api.init_app(blueprint) api.add_namespace(REST_backend_namespace) app.register_blueprint(blueprint) mongo.init_app(app)