I have this output from a file
file = open('path', 'r')
file_content = file.read()
file_content =
123
123
123
I'm creating the following json to serve as reply for a api using flask:
var = file_content
return jsonify({'result':var})
The curl output is
123\n123\n123\n
Is there a way to make the json display as such, every single "123" on a new line and the '\n' removed? :
{result: '123
123
123'
Even an article would be good to guide me on how to accomplish this, basically I want to prittyprint the response..
flask code as reference:
from flask import Flask, jsonify, request
import start, tempData
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
@app.route('/test<int:num>', methods=['GET'])
def callMainF(num):
start.cicleInfotypes(num)
return jsonify({'result':tempData.getOuput()})
fvariable inf.read()an opened file?{'bookpage1': 'AllTheTextFromAPage'}