old_contents: """Web app that serves proselint's API."""
  
  from flask import Flask, request, jsonify
  from flask_cors import CORS, cross_origin
  import uuid
  import os
  import urllib2
  import io
  from proselint import command_line
  from rq import Queue
  from worker import conn
  
  app = Flask(__name__)
  cors = CORS(app)
  app.config['CORS_HEADERS'] = "Origin, X-Requested-With, Content-Type, Accept"
  
  q = Queue(connection=conn)
  
  
  def worker_function(text):
      """Lint the text using a worker dyno."""
      id = uuid.uuid4()
      filename = os.path.join("tmp", "{}.md".format(id))
      with io.open(filename, "w+", encoding='utf8') as f:
          f.write(text)
  
      return command_line.lint(filename)
  
  
  @app.route('/v1/', methods=['GET', 'POST'])
  @cross_origin()  # allow all origins all methods.
  def lint():
      """Run linter on the provided text and return the results."""
      if 'text' in request.values:
          text = urllib2.unquote(request.values['text'])
          job = q.enqueue(worker_function, text)
  
          return jsonify(job_id=job.id), 202
  
      elif 'job_id' in request.values:
          job = q.fetch_job(request.values['job_id'])
  
          if not job:
              return jsonify(
                  status="error",
                  message="No job with requested job_id."), 404
  
          elif not job.result:
              return jsonify(
                  status="error",
                  message="Job is not yet ready."), 202
  
          else:
              errors = []
              for i, e in enumerate(job.result):
                  app.logger.debug(e)
                  errors.append({
                      "line": e[0],
                      "column": e[1],
                      "err": e[2],
                      "msg": e[3],
                  })
              return jsonify(
                  status="success",
                  data={"errors": errors})
  
  
  if __name__ == '__main__':
      app.debug = True
      app.run()
  
new_contents: """Web app that serves proselint's API."""
  
  from flask import Flask, request, jsonify
  from flask_cors import CORS, cross_origin
  import uuid
  import os
  import urllib2
  import io
  from proselint import command_line
  from rq import Queue
  from worker import conn
  
  app = Flask(__name__)
  cors = CORS(app)
  app.config['CORS_HEADERS'] = "Origin, X-Requested-With, Content-Type, Accept"
  
  q = Queue(connection=conn)
  
  
  def worker_function(text):
      """Lint the text using a worker dyno."""
      id = uuid.uuid4()
      filename = os.path.join("tmp", "{}.md".format(id))
      with io.open(filename, "w+", encoding='utf8') as f:
          f.write(text)
  
      return command_line.lint(filename)
  
  
  @app.route('/v1/', methods=['GET', 'POST'])
  @cross_origin()  # allow all origins all methods.
  def lint():
      """Run linter on the provided text and return the results."""
      if 'text' in request.values:
          text = urllib2.unquote(request.values['text'])
          job = q.enqueue(worker_function, text)
  
          return jsonify(job_id=job.id), 202
  
      elif 'job_id' in request.values:
          job = q.fetch_job(request.values['job_id'])
  
          if not job:
              return jsonify(
                  status="error",
                  message="No job with requested job_id."), 404
  
          elif job.result is None:
              return jsonify(
                  status="error",
                  message="Job is not yet ready."), 202
  
          else:
              errors = []
              for i, e in enumerate(job.result):
                  app.logger.debug(e)
                  errors.append({
                      "line": e[0],
                      "column": e[1],
                      "err": e[2],
                      "msg": e[3],
                  })
              return jsonify(
                  status="success",
                  data={"errors": errors})
  
  
  if __name__ == '__main__':
      app.debug = True
      app.run()
  
subject: Fix bug in API