示例#1
0
def app():
    app = SkyLines(config_file=config.TESTING_CONF_PATH)
    _db.init_app(app)

    oauth.init_app(app)
    cors.init_app(app)

    @app.route('/secrets')
    @oauth.required()
    def secrets():
        return jsonify({'secrets': [1, 1, 2, 3, 5, 8, 13]})

    @app.route('/user')
    @oauth.optional()
    def user():
        return jsonify({'user': request.user_id})

    return app
示例#2
0
def app():
    app = SkyLines(config_file=config.TESTING_CONF_PATH)
    _db.init_app(app)

    oauth.init_app(app)
    cors.init_app(app)

    @app.route('/secrets')
    @oauth.required()
    def secrets():
        return jsonify({'secrets': [1, 1, 2, 3, 5, 8, 13]})

    @app.route('/user')
    @oauth.optional()
    def user():
        return jsonify({'user': request.user_id})

    return app
示例#3
0
def app():
    app = SkyLines(config_file=config.TESTING_CONF_PATH)
    app.response_class = ApiResponse
    _db.init_app(app)

    oauth.init_app(app)
    cors.init_app(app)

    @app.route("/secrets")
    @oauth.required()
    def secrets():
        return jsonify({"secrets": [1, 1, 2, 3, 5, 8, 13]})

    @app.route("/user")
    @oauth.optional()
    def user():
        return jsonify({"user": request.user_id})

    return app
示例#4
0
def app():
    app = SkyLines(config_file=config.TESTING_CONF_PATH)
    app.response_class = ApiResponse
    _db.init_app(app)

    oauth.init_app(app)
    cors.init_app(app)

    @app.route("/secrets")
    @oauth.required()
    def secrets():
        return jsonify({"secrets": [1, 1, 2, 3, 5, 8, 13]})

    @app.route("/user")
    @oauth.optional()
    def user():
        return jsonify({"user": request.user_id})

    return app
示例#5
0
def register(app):
    """
    :param flask.Flask app: a Flask app
    """

    from .errors import register as register_error_handlers

    @app.before_request
    def require_user_agent():
        """
        API requests require a ``User-Agent`` header
        """
        user_agent = request.user_agent
        assert isinstance(user_agent, UserAgent)

        if not user_agent.string:
            description = "You don't have the permission to access the API with a User-Agent header."
            raise Forbidden(description)

    cors.init_app(app)

    register_error_handlers(app)

    app.register_blueprint(about_blueprint)
    app.register_blueprint(account_blueprint)
    app.register_blueprint(airports_blueprint)
    app.register_blueprint(aircraft_models_blueprint)
    app.register_blueprint(clubs_blueprint)
    app.register_blueprint(flights_blueprint)
    app.register_blueprint(groupflights_blueprint)
    app.register_blueprint(i18n_blueprint)
    app.register_blueprint(mapitems_blueprint)
    app.register_blueprint(notifications_blueprint)
    app.register_blueprint(ranking_blueprint)
    app.register_blueprint(search_blueprint)
    app.register_blueprint(settings_blueprint)
    app.register_blueprint(statistics_blueprint)
    app.register_blueprint(timeline_blueprint)
    app.register_blueprint(tracking_blueprint)
    app.register_blueprint(upload_blueprint)
    app.register_blueprint(users_blueprint)
示例#6
0
def register(app):
    """
    :param flask.Flask app: a Flask app
    """

    from .errors import register as register_error_handlers
    from .airports import airports_blueprint
    from .airspace import airspace_blueprint
    from .clubs import clubs_blueprint
    from .mapitems import mapitems_blueprint
    from .search import search_blueprint
    from .users import users
    from .user import user
    from .waves import waves_blueprint

    @app.before_request
    def require_user_agent():
        """
        API requests require a ``User-Agent`` header
        """
        user_agent = request.user_agent
        assert isinstance(user_agent, UserAgent)

        if not user_agent.string:
            description = 'You don\'t have the permission to access the API with a User-Agent header.'
            raise Forbidden(description)

    cors.init_app(app)
    oauth.init_app(app)

    register_error_handlers(app)

    app.register_blueprint(airports_blueprint)
    app.register_blueprint(airspace_blueprint)
    app.register_blueprint(clubs_blueprint)
    app.register_blueprint(mapitems_blueprint)
    app.register_blueprint(search_blueprint)
    app.register_blueprint(user)
    app.register_blueprint(users)
    app.register_blueprint(waves_blueprint)
示例#7
0
def register(app):
    """
    :param flask.Flask app: a Flask app
    """

    from .errors import register as register_error_handlers

    @app.before_request
    def require_user_agent():
        """
        API requests require a ``User-Agent`` header
        """
        user_agent = request.user_agent
        assert isinstance(user_agent, UserAgent)

        if not user_agent.string:
            description = 'You don\'t have the permission to access the API with a User-Agent header.'
            raise Forbidden(description)

    cors.init_app(app)

    register_error_handlers(app)

    app.register_blueprint(about_blueprint)
    app.register_blueprint(account_blueprint)
    app.register_blueprint(airports_blueprint)
    app.register_blueprint(aircraft_models_blueprint)
    app.register_blueprint(clubs_blueprint)
    app.register_blueprint(flights_blueprint)
    app.register_blueprint(i18n_blueprint)
    app.register_blueprint(mapitems_blueprint)
    app.register_blueprint(notifications_blueprint)
    app.register_blueprint(ranking_blueprint)
    app.register_blueprint(search_blueprint)
    app.register_blueprint(settings_blueprint)
    app.register_blueprint(statistics_blueprint)
    app.register_blueprint(timeline_blueprint)
    app.register_blueprint(tracking_blueprint)
    app.register_blueprint(upload_blueprint)
    app.register_blueprint(users_blueprint)
示例#8
0
def register(app):
    """
    :param flask.Flask app: a Flask app
    """

    from .errors import register as register_error_handlers
    from .airports import airports_blueprint
    from .airspace import airspace_blueprint
    from .clubs import clubs_blueprint
    from .mapitems import mapitems_blueprint
    from .search import search_blueprint
    from .users import users
    from .user import user
    from .waves import waves_blueprint

    @app.before_request
    def require_user_agent():
        """
        API requests require a ``User-Agent`` header
        """
        user_agent = request.user_agent
        assert isinstance(user_agent, UserAgent)

        if not user_agent.string:
            description = 'You don\'t have the permission to access the API with a User-Agent header.'
            raise Forbidden(description)

    cors.init_app(app)
    oauth.init_app(app)

    register_error_handlers(app)

    app.register_blueprint(airports_blueprint)
    app.register_blueprint(airspace_blueprint)
    app.register_blueprint(clubs_blueprint)
    app.register_blueprint(mapitems_blueprint)
    app.register_blueprint(search_blueprint)
    app.register_blueprint(user)
    app.register_blueprint(users)
    app.register_blueprint(waves_blueprint)