You can use something like that with your cgi function. After you recieve a request you run that function:
import os
def return_file(name):
filepath = os.path.join('/path/to/your/cgi-bin', name)
if os.path.isfile(filepath):
return open(filepath, 'b').read()
It will return content of your file in binary mode and you'll can return it as any MIME-format you want.