-1

I'm trying to upload xls in my application and then processing it in backend i.e.python flask, the below code works in ubuntu 14.04 but fails in Heroku with Attribute Error 'Request' object has no attribute 'get_array'

Code as below

import flask_excel as excel

try:
    if request.method == 'POST':
        file_obj = request.get_array(field_name='file')

Error in heroku is for the request.get_array 'Request' object has no attribute 'get_array'

My requirements.txt in heroku has the below

Flask-Excel==0.0.7
pyexcel-xls==0.5.7

My HTML code is below

<form action="/upload_contacts" method="post" enctype="multipart/form-data">
   <input type="file" name="file">
   <button type="submit" class="btn btn-primary">Add Contacts</button>
</form>

I am referring this http://flask-excel.readthedocs.io/en/latest/ link for uploading .xls/.xlsx file.
I did try searching for a fix, in github someone mentioned I have to use from flask.ext import excel but this seems deprecated now and replaced by flask_excel.

Please suggest how to fix this issue.

Thanks

Seema
  • 41
  • 1
  • 4
  • This code working on Ubuntu 14.04 but failed on Heroku, – Seema Jun 06 '18 at 04:40
  • I do not understand why this question was closed and directed to a question that is not helpful, get_array is specific to the Flask-excel package and is only available if you have installed it – Moses N. Njenga Nov 17 '21 at 10:40
  • !! you can check the flask_excel ```flask_excel/__init__.py``` you will find init_excel function, to be able to use request.get_array you must setup flask_excel first by calling this function, you imported flask_excel as excel so code should be: ```excel.init_excel(app)``` – Mahmoud Magdy Apr 02 '23 at 10:02

1 Answers1

0

maybe you want to use request.args it return MultiDict

request.args[<paramname>] get first find param, 

request.args.getlist(<paramname>) get a list

docs

Druta Ruslan
  • 7,171
  • 2
  • 28
  • 38