-1

I currently have a python server using flask tht allows me to send data from postman to it. It works perfectly and the output shows up in the terminal for the flask/python app. However, I would like the output to be sent back to postman so the "frontend" can use it. How can I do this?

Code:

from flask import Flask, request
from flask_restful import Resource, Api
from server import analyzeWeaknesses, printOutput

app = Flask(__name__)
api = Api(app)

@app.route('/analyzeTrucks', methods=['POST'])
def TruckAnalysis():

    if request.method == 'POST':
        analyzeTrucks(request.data)
        return {"status":"success"}

if __name__ == '__main__': 
    app.run()  
Juliette
  • 4,309
  • 2
  • 14
  • 31

1 Answers1

0

if you want to send json data to frontend then use jsonify

from flask import Flask, jsonify
...
...
return jsonify({
        'status': 'success',
        'alive': True,
        'version': __version__
    })
anunaki
  • 989
  • 9
  • 16