"""Simple blueprint."""
import os

from flask import Blueprint, current_app, render_template

blueprint = Blueprint('simple', __name__, url_prefix='/simple',
                   template_folder='templates')


@blueprint.route('', methods=['GET'])
def get_simple():
    """List all packages."""
    packages = os.listdir(current_app.config['BASEDIR'])
    return render_template('simple.html', packages=packages)


@blueprint.route('/<package>', methods=['GET'])
@blueprint.route('/<package>/', methods=['GET'])
def get_package(package):
    """List versions of a package."""
    package_path = os.path.join(current_app.config['BASEDIR'],
                                package.lower())
    files = os.listdir(package_path)

    packages = []
    for filename in files:
        if filename.endswith('md5'):
            with open(os.path.join(package_path, filename), 'r') as md5_digest: 
                item = {
                    'name': package,
                    'version': filename.replace('.md5', ''),
                    'digest': md5_digest.read()
                }
                packages.append(item)
    return render_template('simple_package.html', packages=packages,
                           letter=package[:1].lower())

"""Simple blueprint."""
import os

from flask import Blueprint, current_app, make_response, render_template

blueprint = Blueprint('simple', __name__, url_prefix='/simple',
                   template_folder='templates')


@blueprint.route('', methods=['POST'])
def search_simple():
    """Handling pip search."""
    return make_response('Not implemented', 501)


@blueprint.route('', methods=['GET'])
def get_simple():
    """List all packages."""
    packages = os.listdir(current_app.config['BASEDIR'])
    return render_template('simple.html', packages=packages)


@blueprint.route('/<package>', methods=['GET'])
@blueprint.route('/<package>/', methods=['GET'])
def get_package(package):
    """List versions of a package."""
    package_path = os.path.join(current_app.config['BASEDIR'],
                                package.lower())
    files = os.listdir(package_path)

    packages = []
    for filename in files:
        if filename.endswith('md5'):
            with open(os.path.join(package_path, filename), 'r') as md5_digest: 
                item = {
                    'name': package,
                    'version': filename.replace('.md5', ''),
                    'digest': md5_digest.read()
                }
                packages.append(item)
    return render_template('simple_package.html', packages=packages,
                           letter=package[:1].lower())

Return 501 on pip search requests
Return 501 on pip search requests

  """Simple blueprint."""
  import os
  
- from flask import Blueprint, current_app, render_template
+ from flask import Blueprint, current_app, make_response, render_template
  
  blueprint = Blueprint('simple', __name__, url_prefix='/simple',
                     template_folder='templates')
+ 
+ 
+ @blueprint.route('', methods=['POST'])
+ def search_simple():
+     """Handling pip search."""
+     return make_response('Not implemented', 501)
  
  
  @blueprint.route('', methods=['GET'])
  def get_simple():
      """List all packages."""
      packages = os.listdir(current_app.config['BASEDIR'])
      return render_template('simple.html', packages=packages)
  
  
  @blueprint.route('/<package>', methods=['GET'])
  @blueprint.route('/<package>/', methods=['GET'])
  def get_package(package):
      """List versions of a package."""
      package_path = os.path.join(current_app.config['BASEDIR'],
                                  package.lower())
      files = os.listdir(package_path)
  
      packages = []
      for filename in files:
          if filename.endswith('md5'):
              with open(os.path.join(package_path, filename), 'r') as md5_digest: 
                  item = {
                      'name': package,
                      'version': filename.replace('.md5', ''),
                      'digest': md5_digest.read()
                  }
                  packages.append(item)
      return render_template('simple_package.html', packages=packages,
                             letter=package[:1].lower())
  
Return 501 on pip search requests
## Code Before:
"""Simple blueprint."""
import os

from flask import Blueprint, current_app, render_template

blueprint = Blueprint('simple', __name__, url_prefix='/simple',
                   template_folder='templates')


@blueprint.route('', methods=['GET'])
def get_simple():
    """List all packages."""
    packages = os.listdir(current_app.config['BASEDIR'])
    return render_template('simple.html', packages=packages)


@blueprint.route('/<package>', methods=['GET'])
@blueprint.route('/<package>/', methods=['GET'])
def get_package(package):
    """List versions of a package."""
    package_path = os.path.join(current_app.config['BASEDIR'],
                                package.lower())
    files = os.listdir(package_path)

    packages = []
    for filename in files:
        if filename.endswith('md5'):
            with open(os.path.join(package_path, filename), 'r') as md5_digest: 
                item = {
                    'name': package,
                    'version': filename.replace('.md5', ''),
                    'digest': md5_digest.read()
                }
                packages.append(item)
    return render_template('simple_package.html', packages=packages,
                           letter=package[:1].lower())

## Instruction:
Return 501 on pip search requests
## Code After:
"""Simple blueprint."""
import os

from flask import Blueprint, current_app, make_response, render_template

blueprint = Blueprint('simple', __name__, url_prefix='/simple',
                   template_folder='templates')


@blueprint.route('', methods=['POST'])
def search_simple():
    """Handling pip search."""
    return make_response('Not implemented', 501)


@blueprint.route('', methods=['GET'])
def get_simple():
    """List all packages."""
    packages = os.listdir(current_app.config['BASEDIR'])
    return render_template('simple.html', packages=packages)


@blueprint.route('/<package>', methods=['GET'])
@blueprint.route('/<package>/', methods=['GET'])
def get_package(package):
    """List versions of a package."""
    package_path = os.path.join(current_app.config['BASEDIR'],
                                package.lower())
    files = os.listdir(package_path)

    packages = []
    for filename in files:
        if filename.endswith('md5'):
            with open(os.path.join(package_path, filename), 'r') as md5_digest: 
                item = {
                    'name': package,
                    'version': filename.replace('.md5', ''),
                    'digest': md5_digest.read()
                }
                packages.append(item)
    return render_template('simple_package.html', packages=packages,
                           letter=package[:1].lower())
