def configure(config): from flask import Blueprint, Flask from . import routes directory = os.path.dirname(os.path.realpath(__file__)) app = Flask(__name__, static_url_path="/BASE_STATIC", template_folder=os.path.join(directory, 'templates')) app.config['APPLICATION_ROOT'] = config['jade']['wsgi']['application_root'] app.url_map.strict_slashes = False # Configure routes bp = Blueprint('jade', __name__, static_folder=os.path.join(directory, 'static'), url_prefix=config['jade']['wsgi']['url_prefix']) trusted_clients = TrustedClients.from_config(config) centralauth = CentralAuth.from_config(config) # state_store = StateStore.from_config(config) state_store = None bp = routes.configure(config, bp, trusted_clients, centralauth, state_store) app.register_blueprint(bp) # Configure swagger-ui routes swagger_bp = flask_swaggerui.build_static_blueprint( 'jade-swaggerui', __name__, url_prefix=config['jade']['wsgi']['url_prefix']) app.register_blueprint(swagger_bp) @app.errorhandler(errors.RequestError) def handle_request_error(e): responses.format_request_error(e) @app.errorhandler(Exception) def handle_unknown_error(e): responses.format_unknown_error(e) return app
def configure(config): from flask import Blueprint, Flask from . import routes from ..scoring_systems import ScoringSystem directory = os.path.dirname(os.path.realpath(__file__)) app = Flask(__name__, static_url_path="/BASE_STATIC", template_folder=os.path.join(directory, 'templates')) app.config['APPLICATION_ROOT'] = config['ores']['wsgi']['application_root'] app.url_map.strict_slashes = False # Configure routes bp = Blueprint('ores', __name__, static_folder=os.path.join(directory, 'static'), url_prefix=config['ores']['wsgi']['url_prefix']) ss_name = config['ores']['scoring_system'] scoring_system = ScoringSystem.from_config(config, ss_name) bp = routes.configure(config, bp, scoring_system) app.register_blueprint(bp) # Configure swagger-ui routes swagger_bp = flask_swaggerui.build_static_blueprint( 'ores-swaggerui', __name__, url_prefix=config['ores']['wsgi']['url_prefix']) app.register_blueprint(swagger_bp) # Configure WikimediaUI routes wikimedia_bp = flask_wikimediaui.build_static_blueprint( 'ores-wikimediaui', __name__, url_prefix=config['ores']['wsgi']['url_prefix']) app.register_blueprint(wikimedia_bp) return app
'description': 'The text language.', 'required': True, 'type': 'string', 'enum': sorted(language_code_to_model_name.keys()) } ], 'consumes': [ 'text/plain; charset=utf-8' ], 'produces': [ 'text/plain; charset=utf-8' ], 'responses': { '200': { 'description': 'The parsing result in the CoNLL-U format http://universaldependencies.org/format.html' }, '400': { 'description': 'Bad request, usually because the Content-Language is not supported' } } } } } }) app.register_blueprint(build_static_blueprint('swaggerui', __name__)) if __name__ == '__main__': app.run(port=7000)
from flask import Flask, jsonify from flask_swaggerui import render_swaggerui, build_static_blueprint app = Flask(__name__) @app.route('/') def root(): return render_swaggerui(swagger_spec_path="/spec") @app.route('/spec') def spec(): return jsonify({"some swagger": "spec stuff"}) # Adds static assets for swagger-ui to path app.register_blueprint(build_static_blueprint("swaggerui", __name__)) if __name__ == "__main__": app.run(port=8080, debug=True)