from flask import Blueprint, request, jsonify, abort from amiibo.amiibo import CharacterHex from amiibo.manager import AmiiboManager characterApp = Blueprint("character", __name__) amiibo_manager = AmiiboManager.from_json() # character API @characterApp.route('/api/character/', methods=['GET']) def route_api_character(): args = request.args if 'key' in args: try: key = CharacterHex(args['key'].strip()) except ValueError: abort(400) result = amiibo_manager.characters.get(key) else: filters = {} if 'name' in args: filters['name'] = args['name'].strip() result = amiibo_manager.characters.filter(**filters) if 'sort' in args: values = { 'key': 'id', 'name': 'name', }
application = app # Register app blueprints app.register_blueprint(gameseriesApp) app.register_blueprint(amiiboseriesApp) app.register_blueprint(typeApp) app.register_blueprint(characterApp) app.register_blueprint(amiiboApp) app.register_blueprint(amiibofullApp) CORS(app) app.json_encoder = AmiiboJSONEncoder Compress(app) amiibo_manager = AmiiboManager.getInstance() # Index @app.route('/') def index(): return render_template('home.html') # Documentation @app.route('/docs/') def documentation(): return render_template('docs.html') # FAQs