"""Module for the solutions of course4.py""" import os import csv import logging as logger from flask import jsonify, request from flask_restplus import Resource, fields from werkzeug.exceptions import BadRequest from solutions import create_api, create_app, mainTitle, course4_field_names app = create_app() # pylint: disable=invalid-name api = create_api(app, mainTitle, 'Example Employee API') # pylint: disable=invalid-name CSV_FILE_NAME = '/../example.csv' API_MODEL = api.model('Employee', { 'employee_id': fields.Integer(required=True, description='Id of the employee'), 'name': fields.String(required=True, min_length=1, max_length=200, description='Name of the employee')}) logger.getLogger().setLevel(logger.INFO) @api.route('/employee/<string:employee_id>') class Csv(Resource): """Class for the employee API""" @staticmethod def get(employee_id): """GET endpoint for retrieving employee info with the given employee_id"""
"""Module for the solutions of course1.py""" import os from flask_restplus import Resource from solutions import create_app, create_api, MY_NAME, QUESTION1_TEMPLATE from texts import mainTitle, descriptiveTextCourse1 app = create_app() # pylint: disable=invalid-name api = create_api(app, mainTitle, descriptiveTextCourse1) # pylint: disable=invalid-name @api.route('/myname') class Question1(Resource): """Endpoint for /myname""" @staticmethod def get(): """GET endpoint for /myname""" return QUESTION1_TEMPLATE.format(MY_NAME) @api.route('/mynameUppercase') class Question2(Resource): """Endpoint for /mynameUppercase""" @staticmethod def get(): """GET endpoint for /mynameUppercase""" return QUESTION1_TEMPLATE.format(MY_NAME).upper() @api.route('/concattedStrings')
"""Module for the solutions of course3.py""" import os from flask import request from flask import jsonify from flask_restplus import Resource from flask_restplus import Api, Resource, fields from werkzeug.exceptions import BadRequest from solutions import create_api, create_app, mainTitle, \ awesome_dictionary_to_return app = create_app() # pylint: disable=invalid-name api = create_api(app, mainTitle, 'Course 3 Solution') # pylint: disable=invalid-name API_MODEL = api.model( 'AwesomeDictionary', { 'Original request': fields.String(required=True, min_length=1, max_length=200, description='Original request') }) @api.route('/jsonify') class Jsonify(Resource): """Endpoint for /jsonify""" @staticmethod @api.doc(responses={200: 'Ok'})