How to deploy a Flask app that uses Camelot to Heroku?

Viewed 121

camelot-py has dependencies: Ghostscript and Tkinter. I'm using a buildpack for Ghostscript. Not sure what to do about Tkinter.

I get an Application Error when I upload this script to Heroku. No issues in the deploying process as I tested with a file that doesn't use camelot-py and it works fine.

Here's my script:

from flask import Flask, jsonify
from waitress import serve
from flask_cors import CORS
import camelot
import json

app = Flask(__name__)
CORS(app)

@app.route('/', methods=['GET'])
def get():
  tables = camelot.read_pdf('https://www.w3.org/WAI/WCAG20/Techniques/working-examples/PDF20/table.pdf')
  tables[0].to_json("dummy.json")
  with open('dummy.json') as f:
    data = json.load(f)
  response = jsonify(data)
  return response

if __name__ == "__main__":
  serve(app, port=5000)
0 Answers
Related