0

When I upload my excel spreadsheet, it is null.

@app.route('/upload', methods=['GET','POST'])
def upload_file():
    if request.method == 'POST':
        return jsonify({'result': request.args.get('file')})
    return '''
    <etc...>
    <form action="" method=post enctype="multipart/form-data">
    <input type=file name=file><input type=submit value=Upload>
    </form>
    '''

The filenames are matching however. Anyone have any insight?

davidism
  • 121,510
  • 29
  • 395
  • 339
Ryan Brady
  • 331
  • 1
  • 2
  • 9
  • 1
    It will be hard to say with the given information. Try two things. First, open up your network tab on chrome dev tools and inspect your request to make sure it looks as you expect it. Second, on the server, make sure the jsonified result looks as expected. – maininformer Jul 11 '18 at 19:50

1 Answers1

0

I was using the improper method. This is the updated code

@app.route('/upload', methods=['GET','POST])
def upload_file():
    if request.method == 'POST':
        return jsonify({'result': request.get_array(field_name='file')})
    return '''
    <etc...>
    <form action="" method=post enctype="multipart/form-data">
    <input type=file name=file><input type=submit value=Upload>
    </form>
    '''

Some simple errors I had made were not initializing flask_excel and setting my flask app twice, which cause an AttributeError on the request.get_array method.

Ryan Brady
  • 331
  • 1
  • 2
  • 9