Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23160

Having trouble with jsonify in Flask

$
0
0

I am fairly new to Flask and am currently working on a project whose goal is to transcribe mp3 files into JSON. I decided to attempt to use Flask, but it's been more challenging than I thought.

As of right now, I am able to display a example JSON file in one of my html pages, but I have not been able to format it. I looked at some previous answers that told me to use jsonify, but it hasn't worked apparently. If you guys could give me a hand, any kind of comment would be really apreciated. Here is my code:

from flask import Flask, render_template, url_for, request, redirect, json, jsonifyimport jsonimport osfrom pathlib import Pathapp = Flask(__name__)@app.route('/')def index():    return render_template('index.html')@app.route('/upload', methods=['POST'])def upload():    file = request.files['inputFile']    if Path(file.filename).suffix == '.mp3':        filename = os.path.join(app.static_folder, 'data', 'json_test.json')        with open(filename) as json_test:            data = json.load(json_test)        return render_template('index2.html', data=data)    else:        return render_template('erro.html')if __name__ == "__main__":    app.run(debug=True)

Viewing all articles
Browse latest Browse all 23160

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>