I'm building a website where users can download various program data and scripts used on that data. I'm wondering if it's possible to download a python script directly? Or do I need to zip it or something?
Right now I list out each python script associated with a program as a link to download. However, the browser says "Failed - Server problem" when I click on the link. I used a test csv file in place of one of the python scripts (in the same folder on the server) and that downloaded successfully, so I have access to the folder where the scripts are.
Just looking to confirm- it's not possible to download a python script directly?
Here is the code in case it's helpful:
var site_url = "<?php echo site_url();?>";
var timestamp="";
var scriptsrendered='<table class="table table-striped">';
i=0;
while (i<v.scripts.length) {
if (v.scripts[i].fldTimestamp===null) {
timestamp ="unknown date";
}
else {
timestamp=new Date(parseInt(v.scripts[i].fldTimestamp)*1000);
}
scriptsrendered+='<tr><td style="width:150px;">'+timestamp+'</td>';
scriptsrendered+='<td><a href="'+site_url+"nefin-temp/nefin_scripts/"+v.scripts[i].fldFileName+'" download="'+v.scripts[i].fldFileName+'">'+v.scripts[i].fldFileName+'</a></td></tr>';
i++;
}
scriptsrendered+='</table>';
$('#programScripts').html(scriptsrendered);
Edit:
I'm not seeing anything in the browser console as far as errors. Php logs are clean also. Apache error log has:
[Wed Jun 08 13:26:37.729794 2022] [fcgid:warn] [pid 65316:tid (104)Connection reset by peer: [client 132.198.100.190:38728] [request de6efb774b83e68d900a90abb805c0d9] mod_fcgid: error reading data from FastCGI server, referer https://dev.vmc.w3.uvm.edu/nefin-xana/extractor
[Wed Jun 08 13:26:37.729823 2022] [core:error] [pid 65316:tid [client 132.198.100.190:38728] [request de6efb774b83e68d900a90abb805c0d9] End of script output before headers: FEMCFHM_munger.py, referer https://dev.vmc.w3.uvm.edu/nefin-xana/extractor
The file is small, so shouldn't be a timeout issue. I'll see if I can figure out if the file type is blocked for download somewhere...