It seems like you have more than one problem here. Let me answer the JSON question though. You need to import json from the flask library and use the json.dumps() method to encode the dictionary object into a JSON string suitable for returning in a response. Please check the sample code below.
from flask import Flask, json
app = Flask('0.0.0.0', port=8080, debug=True)
@app.route('/url', methods=['POST'])
def html_json():
data = {"a": ["https://www.google.hu/",
"https://www.facebook.com/"
]
}
return json.dumps(data), 200
http://flask.pocoo.org/docs/0.12/patterns/fileuploads/ should help with file upload tasks.
Beautiful Soup
BeautifulSoup is a Python library that can be used to parse HTML. This will give you a structured set of elements that you can iterate over and convert into JSON.
from BeautifulSoup import BeautifulSoup
html = "html file as string here"
soup = BeautifulSoup(html)
You can then iterate through each tag in the HTML.
links = soup.find_all('a',href=True)
Here is a question where someone converts a HTML table to JSON (far easier than a whole page): Convert a HTML Table to JSON
I found a blog post which could help. The author created a HTML to JSON Parser: http://www.xavierdupre.fr/blog/2013-10-27_nojs.html