def barcode(): req_vars = request.vars #first_key = list(req_vars.keys() )[0] first_key = next(iter(req_vars) ) reader = BarCodeReader() results = reader.decode(first_key) return results
""" curl -X POST --user admin:password -d '@filename.png' -i http://localhost:8000/test/scan/barcode.json curl -X POST --user admin:password --data-binary '@filename.png' -i http://localhost:8000/test/scan/barcode.json """ *error traceback* Traceback (most recent call last): File "/Users/sugizo/Downloads/web2py/gluon/restricted.py", line 219, in restricted exec(ccode, environment) File "/Users/sugizo/Downloads/web2py/applications/test/controllers/scan.py", line 26, in <module> File "/Users/sugizo/Downloads/web2py/gluon/globals.py", line 430, in <lambda> self._caller = lambda f: f() File "/Users/sugizo/Downloads/web2py/applications/test/controllers/scan.py", line 15, in barcode results = reader.decode(first_key) File "/Users/sugizo/opt/miniconda3/envs/python3_test/lib/python3.7/site-packages/pyzxing/reader.py", line 51, in decode raise FileNotFoundError FileNotFoundError but when check for first_key (in function above just *return first_key*) *the result is * HTTP/1.1 100 Continue HTTP/1.1 200 OK X-Powered-By: web2py Content-Type: application/json Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Fri, 18 Feb 2022 21:50:35 GMT Pragma: no-cache Date: Fri, 18 Feb 2022 21:50:35 GMT Server: Rocket 1.2.6 Python/3.7.11 Content-Length: 417 Connection: keep-alive L@pk��N"��w��Ƙ9m�ϓ�6�*"��������gA�!F��o،�ۅ�p� �5�q�/���f� v��Ɗ��?j'%��q� ��o�Gņ��ږs0���.�2v���O11G0i�k���.[z��b)�;L���Q���c_ so i assume, the first_key is passed by request.vars as a binary but when trying to execute it on terminal (create another file then execute : *python test0.py* it work e.g. *results = reader.decode(filename.png*) *objective* user send data file via curl, and web2py process the file and return it content text *question* any idea how to achieve it using web2py way ? thanks and best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/8421e9c4-5b0b-4687-84d5-539aa29fc9f2n%40googlegroups.com.