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>


Consider following employee schema:

Then custom download controller will be:

If you have any queries related to this code, please comment below.

How to password protect PDF file using Python?

We will use python library PyPDF2 to set password to pdf file. To install PyPDF2: [crayon-58122de50b09d852598667/] We are using encrypt function of PyPDF2. encrypt(user_password, owner_password=None, use_128bit=True) user_password  – The … [Continue reading]

Memory profiling in Python using memory_profiler

To install memory_profiler: [crayon-58122de50b2d5422431937/] Profile function/script: Add following line in script to import memory profiler: [crayon-58122de50b2db444479710/] Decorate the function you would like to profile with … [Continue reading]

Time profiling in python using cProfile

In this article we will cover following points:  Profile single function Profile complete python script How to read .prof file Profile web2py application To install cprofile on ubuntu use following … [Continue reading]

How to measure performance of code ? – Basic methods

In this article, we will cover some very basic methods to calculate performance of script. In next article we will cover advance tool like cProfile and memory_profiler. What is profiling? Profiling is program analysis that measures, for … [Continue reading]

Size Contest (SPOJ Challenge problem 378)

Given the set of integers, find the sum of all positive integers in it. Solutions can be sent in any language supported by SPOJ except Whitespace. Input t – number of test cases [t < 1000] On each of next t lines given a integer N [-1000 <= … [Continue reading]

Factorial (SPOJ problem 11)

View problem on SPOJ The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every phone connects to the BTS with the … [Continue reading]

Check whether one string is rotated version of other(Josh software programming test problem-2)

Write a program to accept two strings str1 and str2 and checks whether str2 is rotated version of str1. Ex. Following are different values of str2 for given str1. GIVEN:str1="software" 2-character left rotate str2='resoft' 4-character left … [Continue reading]

Generate graph from input 1-D array (Josh Software programming test problem-1)

Josh software apti

Following program was asked by Josh Software during campus recruitment. Write a program to generate following chart without using any graph library.This is of marks from 1 to 5 obtained by 10 student represented by an array as … [Continue reading]

Remove duplicate characters in string

Write code to remove the duplicate characters in a string without using any additional buffer NOTE: One or two additional variables are fine An extra copy of the array is not. This question is from the book "cracking thecoding interview". Time … [Continue reading]