EDIT: I adjusted the title because it was marked as a duplicate. And although the error in the duplicate is the same, I need help to understand which Flask / HTML response is returned to update csv with my form variables.
I have a jar application that creates a dynamic graph and extracts it from a csv file.
I want to send new data to csv (and therefore to the chart) by entering through an HTML form. The fact is that this will allow you to update the schedule from a web page, and not edit the local CSV.
Here is a brief snippet of my HTML:
<h1>Input New Polls for Graph</h1> <form method="POST" action="/send"> <input type="text" placeholder="Date"> <input type="text" placeholder="0.2"> <input type = ... <input type="submit" name="Submit"> </form>
This is what the corresponding part of my app.py flash file looks like:
@app.route('/send', methods=['GET', 'POSTS']) def send(): if request.method == 'POST': Date = request.form['Date'] Num1 = request.form['Num1'] Numi = ... newInput = ['Date', 'Num1', 'Numi...'] with open(r'GraphData.csv', 'a') as f: writer = csv.writer(f) writer.writerow(newInput)
In additional code, including the pandas package, the program currently accepts data from my local GraphData.csv file and it displays the graph correctly.
When I go to the local host address with 127 ../ send, I get:
'Error 500, the view function did not return a response .
I know this is probably a logical mistake, but I'm not sure if there is a more efficient or Putin way to accomplish what I'm trying to do here.
python flask forms csv
QuestionableWalrus
source share