def upload():

    if request.method == 'POST':

        file = request.files['file']

        if not allowed_file(file.filename):

            return {
                "status":
                400,
                "msg":
                "provided file type not supported. "
                "Expected pdf document as input"
            }

        if file and file.filename.endswith("pdf"):

            now = datetime.now()
            filename = os.path.join(
                app.config['UPLOAD_FOLDER'],
                "%s.%s" % (now.strftime("%Y-%m-%d-%H-%M-%S-%f"),
                           file.filename.rsplit('.', 1)[1]))
            file.save(filename)
            converter = Convert(filename)
            converter.extract_text()
            converter.convert_text()
            return_file = converter.create_pdf()

            return send_from_directory(directory=os.path.dirname(return_file),
                                       filename=os.path.basename(return_file),
                                       as_attachment=True)