I am creating a webapp using React that takes a csv file as input from user. I want to then work with that csv file in python, then return it to the user so that they can download it.
This is what I have so far:
React (Frontend):
App.js:
function App() {
return(
<UploadFile />
);
}
UploadFile.js:
function Upload(){
return(
<form action="/action_page.php" method="POST" encType="multipart/form-data">
<input type="file" id="dat" name="filename"/>
<input type="submit"/>
</form>
);
}
Python (Backend): working.py
from flask import Flask, render_template, request
from werkzeug import secure_filename
app = Flask(__name__)
@app.route('./upload')
def upload_file():
return render_template('index.html')
@app.route('/uploader', methods = ['POST'])
def upload_file():
f = request.files['file']
f.save(secure_filename(f.filename))
return 'File uploaded'
if __name__ == '__main__':
app.run(debug = True)
I'm completely lost on how to continue. I've sort of followed ideas from Taking user input from HTML form as a variable for Python script and https://pythonbasics.org/flask-upload-file/ but I'm not sure how to continue.
Where is the file saved and what is it saved as? How do I start using it? And is the secure_filename function required?
Can anyone help me on the right track to start using the actual file?
Thanks