<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def serve(opts):
 """ Run a light-weight HTTP server hosting previously mirrored resources """

    resources = _load(opts.resources, opts.output_dir)
    opts.output_dir = resources.output_dir  # allow resources.yaml to set default output_dir
    if not os.path.exists(opts.output_dir):
        sys.stderr.write("Resources dir '{}' not found.  Did you fetch?\n".format(opts.output_dir))
        return 1
    backend.PyPIResource.build_pypi_indexes(opts.output_dir)
    os.chdir(opts.output_dir)

    HTTPServer.allow_reuse_address = True
    httpd = HTTPServer((opts.host, opts.port), SimpleHTTPRequestHandler)

    if opts.ssl_cert:
        httpd.socket = ssl.wrap_socket(httpd.socket, certfile=opts.ssl_cert, server_side=True)

    print("Serving at: http{}://{}:{}/".format(
        's' if opts.ssl_cert else '', socket.gethostname(), opts.port))
    httpd.serve_forever()