I am completely new to this so apologies if the question is a bit vague. I need to know where to start.
I am trying to make a simple setup with the following flow:
- User uploads a CSV file to HTML form, file is sent (see below) to the server.
- Server is running a python script that takes the CSV and turns it into an array.
- The python script runs functions on the array and makes a new array of information.
- This new array is sent back to the HTML webpage as an array that will be shown to the user through Javascript DOM.
I know how to do everything on the front-end and the processing in python. My question is, how would the file be sent to the server (would the form be submitted with GET or POST, etc.) and how can I make this like the diagram attached? Any guidance is appreciated.
Edit 5/10/20
My front-end code would look like this:
function sendfile(){
var file = document.getElementById("uploadfile").value;
$.post('localhost:22222', //this is where I am hosting the server
{SendData: file},
function(returnedArray) {
var newData = //the response from python server, in array format;
//set up different variables from the array
//update the returned_info div with the new data
})
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form>
Upload your file here:
<input type="file" id="uploadfile">
<button onclick="sendfile()">Submit!</button>
</form>
<div id="returned_info">
</div>
Is the above code correct, or is there anything I can improve?
How would I properly receive the request in the python server, so it can convert that CSV file to an array, like this? After the server is done getting data and making calculations from this original array, how can I have it send another array back to the HTML page to be used by jQuery callback (See code)?
I am using this reference.