From d938937d488d03060ca5f7829ccab296bdfc90c6 Mon Sep 17 00:00:00 2001 From: ANormalPerson1 <39001006+ANormalPerson1@users.noreply.github.com> Date: Sat, 23 Mar 2019 09:50:40 +0100 Subject: [PATCH 1/2] request.json -> request.get_json() Apparently, the json method of request is considered deprecated, src https://stackoverflow.com/questions/20001229/how-to-get-posted-json-in-flask So swallep it out for request.get_json --- backend/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/main.py b/backend/main.py index e0c6b55..4a3fcd1 100644 --- a/backend/main.py +++ b/backend/main.py @@ -13,7 +13,7 @@ def load(): def deposit(): #Request .json, store json if request.isJson(): - request.json. + request.get_json() @@ -27,4 +27,4 @@ def graph(chartID = 'chart_ID', chart_type = 'line', chart_height = 500): return render_template('index.html', chartID=chartID, chart=chart, series=series, title=title, xAxis=xAxis, yAxis=yAxis) if __name__ == "__main__": - app.run(debug = True, host='0.0.0.0', port=8080, passthrough_errors=True) \ No newline at end of file + app.run(debug = True, host='0.0.0.0', port=8080, passthrough_errors=True) From 51d6695fec6ba186dd538b25d567d6581cde1e14 Mon Sep 17 00:00:00 2001 From: ANormalPerson1 <39001006+ANormalPerson1@users.noreply.github.com> Date: Sat, 23 Mar 2019 10:20:53 +0100 Subject: [PATCH 2/2] Attempting request.post and request.get_json Attempting to understand what the various methods do, do to differing documentation on some parts. To current knowledge, get_json gets a json file from the webserver, whilst post uploads one. On to how to access the uploaded json with html, I will work on. --- backend/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/main.py b/backend/main.py index 4a3fcd1..73ad812 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1,5 +1,6 @@ from flask import Flask, redirect, url_for, request, render_template app = Flask(__Name__) +URL = "" #Insert url of website here @app.route('/list') def list(): @@ -13,9 +14,12 @@ def load(): def deposit(): #Request .json, store json if request.isJson(): - request.get_json() - + content = request.get_json(url = URL) + return content +@app.route('/post', , methods = ['POST']): +def post(): + request.post(url = URL, data = "") #Insert the data you wish to upload @app.route('/graph') def graph(chartID = 'chart_ID', chart_type = 'line', chart_height = 500):