I am trying to create a route in Odoo 10 to download a binary file for gtfs real-time updater.
I searched in Odoo documentation but I didn't find any similar
This is my controller for test download binary file:
class GtfsRt(http.Controller):
@http.route('/gtfs_rt', type='http', auth='public')
def index(self):
f = open('my_file', 'w+b')
byte_arr = [120, 3, 255, 0, 100]
binary_format = bytearray(byte_arr)
f.write(binary_format)
f.close()
return f
I would like to download the file when I go to /gtfs_rt
At this moment I got this error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 303, in run_wsgi
execute(self.server.app)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 291, in execute
application_iter = app(environ, start_response)
File "/opt/odoo/odoo/service/server.py", line 307, in app
return self.app(e, s)
File "/opt/odoo/odoo/service/wsgi_server.py", line 186, in application
return application_unproxied(environ, start_response)
File "/opt/odoo/odoo/service/wsgi_server.py", line 172, in application_unproxied
result = handler(environ, start_response)
File "/opt/odoo/odoo/http.py", line 1326, in __call__
return self.dispatch(environ, start_response)
File "/opt/odoo/odoo/http.py", line 1300, in __call__
return self.app(environ, start_wrapped)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/middleware/shared_data.py", line 227, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/http.py", line 1505, in dispatch
return response(environ, start_response)
TypeError: 'file' object is not callable