def post_member(): # this is how you can use the Family datastructure by calling its methods body = request.get_json() if 'first_name' not in body or body['first_name'] == "": return 'Invalid member', 400 if 'age' not in body or body['age'] == "": return 'Invalid member', 400 if 'lucky_numbers' not in body or not body['lucky_numbers']: return 'Invalid member', 400 member = FamilyStructure(last_name='Jackson', first_name=body['first_name'], age=body['age'], lucky_numbers=body['lucky_numbers']) body['id'] = jackson_family._generateId() response = jackson_family.add_member(body) return jsonify(response), 200
This module takes care of starting the API Server, Loading the DB and Adding the endpoints """ import os from flask import Flask, request, jsonify, url_for from flask_cors import CORS from utils import APIException, generate_sitemap from datastructures import FamilyStructure import json #from models import Person app = Flask(__name__) app.url_map.strict_slashes = False CORS(app) # create the jackson family object jackson_family = FamilyStructure("Jackson") # Handle/serialize errors like a JSON object @app.errorhandler(APIException) def handle_invalid_usage(error): return jsonify(error.to_dict()), error.status_code # generate sitemap with all your endpoints @app.route('/') def sitemap(): return generate_sitemap(app) @app.route('/members', methods=['GET'])
""" This module takes care of starting the API Server, Loading the DB and Adding the endpoints """ import os from flask import Flask, request, jsonify, url_for from flask_cors import CORS from utils import APIException, generate_sitemap from datastructures import FamilyStructure #from models import Person app = Flask(__name__) app.url_map.strict_slashes = False CORS(app) # create the jackson family object jackson_family = FamilyStructure("Jackson") john_jackson = { "id": jackson_family._generateId(), "name": "John Jackson", "age": 33, "lucky_members": [7, 13, 22] } jane_jackson = { "id": jackson_family._generateId(), "name": "Jane Jackson", "age": 35, "lucky_members": [10, 14, 3] } jimmy_jackson = { "id": jackson_family._generateId(), "name": "Jimmy Jackson",
This module takes care of starting the API Server, Loading the DB and Adding the endpoints """ import os import json from flask import Flask, request, jsonify, url_for from flask_cors import CORS from utils import APIException, generate_sitemap from datastructures import FamilyStructure #from models import Person app = Flask(__name__) app.url_map.strict_slashes = False CORS(app) # create the jackson family object jackson_family = FamilyStructure("Jackson") jackson_family.add_member({ "first_name": "John", "age": 33, "lucky_numbers": [7, 13, 22] }) jackson_family.add_member({ "first_name": "Jane", "age": 35, "lucky_numbers": [10, 14, 3] }) jackson_family.add_member({ "first_name": "Jimmy", "age": 5,
""" This module takes care of starting the API Server, Loading the DB and Adding the endpoints """ import os from flask import Flask, request, jsonify, url_for from flask_cors import CORS from utils import APIException, generate_sitemap from datastructures import FamilyStructure #from models import Person app = Flask(__name__) app.url_map.strict_slashes = False CORS(app) # create the jackson family object jackson_family = FamilyStructure("Apellido") # Handle/serialize errors like a JSON object @app.errorhandler(APIException) def handle_invalid_usage(error): return jsonify(error.to_dict()), error.status_code # generate sitemap with all your endpoints @app.route('/') def sitemap(): return generate_sitemap(app) @app.route('/members', methods=['GET', 'POST'])
This module takes care of starting the API Server, Loading the DB and Adding the endpoints """ import os from flask import Flask, request, jsonify, url_for from flask_cors import CORS from utils import APIException, generate_sitemap from datastructures import FamilyStructure import json #from models import Person app = Flask(__name__) app.url_map.strict_slashes = False CORS(app) # create the jackson family object jackson_family = FamilyStructure('last_name') # Handle/serialize errors like a JSON object @app.errorhandler(APIException) def handle_invalid_usage(error): return jsonify(error.to_dict()), error.status_code # generate sitemap with all your endpoints @app.route('/') def sitemap(): return generate_sitemap(app) @app.route('/members', methods=['GET'])
from utils import APIException, generate_sitemap from admin import setup_admin from models import db, User from datastructures import FamilyStructure #from models import Person app = Flask(__name__) app.url_map.strict_slashes = False # app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DB_CONNECTION_STRING') app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False # MIGRATE = Migrate(app, db) # db.init_app(app) CORS(app) # setup_admin(app) smith_family = FamilyStructure("Smith") # Handle/serialize errors like a JSON object @app.errorhandler(APIException) def handle_invalid_usage(error): return jsonify(error.to_dict()), error.status_code # generate sitemap with all your endpoints @app.route('/') def sitemap(): return generate_sitemap(app) @app.route('/members')
""" This module takes care of starting the API Server, Loading the DB and Adding the endpoints """ import os, json from flask import Flask, request, jsonify, url_for from flask_cors import CORS from utils import APIException, generate_sitemap from datastructures import FamilyStructure #from models import Person app = Flask(__name__) app.url_map.strict_slashes = False CORS(app) jackson_family = FamilyStructure('Jackson') # Handle/serialize errors like a JSON object @app.errorhandler(APIException) def handle_invalid_usage(error): return jsonify(error.to_dict()), error.status_code # generate sitemap with all your endpoints @app.route('/') def sitemap(): return generate_sitemap(app) @app.route('/members', methods=['GET']) def handle_hello(): # this is how you can use the Family datastructure by calling its methods