Description: I am developing a website, that will take input from file from user (CSV File) and pass that file to backend, where python will perform some processing onto that file, the file should be passed in the form of csv not in json format.At now i am not using any database because i do not have to store that file into my db. The tech that i am using are Angular,Flask, and Python.
**Client side**
main.component.html:
<form action = "http://localhost:5000/uploader" method = "POST" enctype="multipart/form-data" ng-submit="submitGuideDetailsForm()">
<div class="form-group">
<label for="usr">Add your Csv file: </label>
<input type='file' class="form-control" name='file' onchange="angular.element(this).scope().uploadFile(this.files)">
</div>
</form>
main.component.ts:
handleFileInput(files: FileList) {
console.log('Inside File upload function\nFile uploaded');
this.receivedFile = files.item(0);
const isFileupload = true;
console.log(` Received File: ${this.receivedFile}`);
if (isFileupload) {
alert('Csv uploaded');
}
}
**Server side**
main.py:
@app.route('/uploader', methods = ['GET', 'POST'])
def upload_file():
if request.method == 'POST':
f = request.files['file']
f.save(secure_filename(f.filename))
print('Hello World')
return 'file uploaded successfully'
else:
return 'Not received the file'
Problem Statement: The problem i am getting here is that i am not receiving the file at backend, there is not even any error there, when i am uploading the file and checking the backend server link http://localhost:5000/uploader , i am getting this: Not received the file.
Request: I request you people to please help me out with this!!!
Aucun commentaire:
Enregistrer un commentaire