How to assign python variable to Javascript variable in web2py

You might be using following statement to assign python variable to javascript variable on older versions of web2py (<2.9.11), may be because of this question on stackoverflow: http://stackoverflow.com/questions/31216574/how-to-pass-data-from-python-to-javascript-in-web2py var javascript_array = {{=XML(response.json(array))}} 1 var javascript_array =  {{=XML(response.json(array))}} Above statement was working… Read the rest

How to do file validation in web2py and write custom validator to validate files?

In this article, I will explain built in validator IS_IMAGE  and  IS_UPLOAD_FILENAME, also a custom validator. It is important to validate file uploaded on server to restrict malicious files like .py .php, .exe bat etc. Web2py provides 2 validators to… Read the rest

How to write custom download controller in web2py?

Suppose we have employee table with resume as uplaod field. And we want to download file on the basis of employee id. Download  url is like app_name/custom_download/employee_id or <a href="{{=URL('default', 'custom_download', args = employee_id)}}" download> example: www.example.com/default/custom_download/1 Consider following employee… Read the rest