Below are the snippets of my code regarding file upload.
Here is my HTML code where I will choose and upload the file:
<form ng-click="addImportFile()" enctype="multipart/form-data">
    <label for="importfile">Import Time Events File:</label><br><br>
    <label for="select_import_file">SELECT FILE:</label><br>
    <input id="import_file" type="file" class="file btn btn-default" ng-disabled="CutOffListTemp.id== Null" data-show-preview="false">
    <input class="btn btn-primary" type="submit" name="submit" value="Upload" ng-disabled="CutOffListTemp.id== Null"/><br/><br/>
</form>
This is my controller that will link both html and my python file:
angular.module('hrisWebappApp').controller('ImportPayrollCtrl', function ($scope, $state, $stateParams, $http, ngTableParams, $modal, $filter) {
  $scope.addImportFile = function() {
    $http.post('http://127.0.0.1:5000/api/v1.0/upload_file/' + $scope.CutOffListTemp.id, {})
    .success(function(data, status, headers, config) {
      console.log(data);
      if (data.success) {
        console.log('import success!');
      } else {
        console.log('importing of file failed' );
      }
    })
    .error(function(data, status, headers, config) {});
};
This is my python file:
@api.route('/upload_file/<int:id>', methods=['GET','POST'])
@cross_origin(headers=['Content-Type'])
def upload_file(id):
    print "hello"
    try:
        os.stat('UPLOAD_FOLDER')
    except:
        os.mkdir('UPLOAD_FOLDER')
    file = request.files['file']
    print 'filename: ' + file.filename
    if file and allowed_file(file.filename):
        print 'allowing file'
        filename = secure_filename(file.filename)
        path=(os.path.join(current_app.config['UPLOAD_FOLDER'], filename))
        file.save(path) #The end of the line which save the file you uploaded.
        return redirect(url_for('uploaded_file',
                                            filename=filename))
    return '''
        <!doctype html>
        <title>Upload new File</title>
        <h1>Upload new File</h1>
        <p>opsss it seems you uploaded an invalid filename please use .csv only</p>
        <form action="" method=post enctype=multipart/form-data>
          <p><input type=file name=file>
             <input type=submit value=Upload>
        </form>
        '''
And the result in the console gave me this even if I select the correct format of file:
<!doctype html>
<title>Upload new File</title>
<h1>Upload new File</h1>
<p>opsss it seems you uploaded an invalid filename please use .csv only</p>
<form action="" method=post enctype=multipart/form-data>
<p><input type=file name=file>
<input type=submit value=Upload>
</form>
This is not returning to my HTML and I cannot upload the file.