def app(): app = SkyLines(config_file=config.TESTING_CONF_PATH) _db.init_app(app) oauth.init_app(app) @app.route('/') @oauth.require_oauth() def index(): return 'success' return app
def create_api_app(*args, **kw): from skylines.api.oauth import oauth app = create_http_app('skylines.api', *args, **kw) app.config['JSON_SORT_KEYS'] = False app.load_egm96() app.add_cache() oauth.init_app(app) import skylines.api.views skylines.api.views.register(app) return app
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
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
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)