Question

I am creating a web application via python cgi . then after execute the cgi script , sqlite and mysql database files buildup in cgi-bin folder. thus i want to grant download it for users. but cgi-bin folder's files only for execute. so how can i do it?

which kind of script (php,perl,javascript,python etc.) can i use for download this generated database files in cgi-bin?

I haven't any experience with a real web hosting server!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top