-1

I Have two API's one is basically for generating PDF's basing on the data sent.

This first API endpoint below

http://localhost:5000/api/sendReceiptData

Returns a PDF file as an attachment.

The second API will consume the first API and should return a PDF as an attachment in the response. I have tried it out but I get this error TypeError: Object of type bytes is not JSON serializable

How can I therefore return a file response from the first API within this second API

Kally
  • 67
  • 1
  • 8

1 Answers1

0

You need to use send_file method to return pdf file

from flask import Flask, make_response, send_file

app = Flask(__name__)


@app.route("/pdf/<string:filename>")
def return_pdf(filename):

    return send_file(filename)


imerla
  • 1,496
  • 2
  • 12
  • 18