[Solved] python cgi files not executing getting the static file treatment
Added by www139 almost 7 years ago
I'm using lighttpd 1.4.45 on Ubuntu 18LTS in a virtual machine. I have set the document root to a shared folder mounted from the host machine. I bypassed the usual auto-mount permission problem by manually mounting the shared fs instead of using the GUI auto mount.
My problem is that, despite seemingly correctly configuring python as my CGI interpreter, lighttpd still seems to refer to .py files as static files. Loading a python file in any directory (including cgi-bin) results in a prompt to download the file. Firefox was used for testing.
My lighttpd.conf:
server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_redirect",
"mod_cgi",
)
server.document-root = "/home/william/Desktop/Space.io/"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
server.port = 80
index-file.names = ( "index.py", "index.php", "index.html", "index.lighttpd.html" )
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".py", ".php", ".pl", ".fcgi" )
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )
# default listening port for IPv6 falls back to the IPv4 port
## Use ipv6 if available
#include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
My 10-cgi.conf:
# /usr/share/doc/lighttpd/cgi.txt
server.modules += ( "mod_cgi" )
cgi.assign = ( ".pl" => "/usr/bin/perl",
".py" => "/usr/bin/python" )
#$HTTP["url"] =~ "^/cgi-bin/" {
#cgi.assign = ( "" => "" )
#}
## Warning this represents a security risk, as it allow to execute any file
## with a .pl/.py even outside of /usr/lib/cgi-bin.
#
#cgi.assign = (
# ".pl" => "/usr/bin/perl",
# ".py" => "/usr/bin/python",
#)
Replies (6)
RE: python cgi files not executing getting the static file treatment - Added by gstrauss almost 7 years ago
Please put mod_cgi before mod_compress in server.modules. You can check if this is the problem by verifying that if you (or your browser) does not send Accept-Encoding, that it those files are executed by mod_cgi.
RE: python cgi files not executing getting the static file treatment - Added by gstrauss almost 7 years ago
If that's not it, please provide your entire lighttpd conf by having lighttpd print it:lighttpd -p -f /etc/lighttpd/lighttpd.conf
Also, have you restarted lighttpd after enabling modules?
RE: python cgi files not executing getting the static file treatment - Added by www139 almost 7 years ago
I tried changing the position of mod_cgi. I also tried commenting out mod_cgi on the 10-cgi.conf file thinking that maybe there was an overlap in timing between the two files. Neither worked.
Yes, I have restarted lighttpd after each edit/change.
Running lighttpd -p -f /etc/lighttpd/lighttpd.conf outputs the following:
config {
var.PID = 4035
var.CWD = "/etc/lighttpd"
server.modules = ("mod_access", "mod_alias", "mod_cgi", "mod_compress", "mod_redirect")
server.document-root = "/home/william/Desktop/Space.io/"
server.upload-dirs = ("/var/cache/lighttpd/uploads")
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
server.port = 80
index-file.names = ("index.py", "index.php", "index.html", "index.lighttpd.html")
url.access-deny = ("~", ".inc")
static-file.exclude-extensions = (".py", ".php", ".pl", ".fcgi")
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ("application/javascript", "text/css", "text/html", "text/plain")
mimetype.assign = (
".ez" => "application/andrew-inset",
".anx" => "application/annodex",
".atom" => "application/atom+xml",
".atomcat" => "application/atomcat+xml",
".atomsrv" => "application/atomserv+xml",
# 5
".lin" => "application/bbolin",
".cu" => "application/cu-seeme",
".davmount" => "application/davmount+xml",
".dcm" => "application/dicom",
".tsp" => "application/dsptype",
# 10
".es" => "application/ecmascript",
".otf" => "application/font-sfnt",
".ttf" => "application/font-sfnt",
".pfr" => "application/font-tdpfr",
".woff" => "application/font-woff",
# 15
".spl" => "application/futuresplash",
".gz" => "application/gzip",
".hta" => "application/hta",
".jar" => "application/java-archive",
".ser" => "application/java-serialized-object",
# 20
".class" => "application/java-vm",
".js" => "application/javascript",
".json" => "application/json",
".m3g" => "application/m3g",
".hqx" => "application/mac-binhex40",
# 25
".cpt" => "application/mac-compactpro",
".nb" => "application/mathematica",
".nbp" => "application/mathematica",
".mbox" => "application/mbox",
".mdb" => "application/msaccess",
# 30
".doc" => "application/msword",
".dot" => "application/msword",
".mxf" => "application/mxf",
".bin" => "application/octet-stream",
".deploy" => "application/octet-stream",
# 35
".msu" => "application/octet-stream",
".msp" => "application/octet-stream",
".oda" => "application/oda",
".opf" => "application/oebps-package+xml",
".ogx" => "application/ogg",
# 40
".one" => "application/onenote",
".onetoc2" => "application/onenote",
".onetmp" => "application/onenote",
".onepkg" => "application/onenote",
".pdf" => "application/pdf",
# 45
".pgp" => "application/pgp-encrypted",
".key" => "application/pgp-keys",
".sig" => "application/pgp-signature",
".prf" => "application/pics-rules",
".ps" => "application/postscript",
# 50
".ai" => "application/postscript",
".eps" => "application/postscript",
".epsi" => "application/postscript",
".epsf" => "application/postscript",
".eps2" => "application/postscript",
# 55
".eps3" => "application/postscript",
".rar" => "application/rar",
".rdf" => "application/rdf+xml",
".rtf" => "application/rtf",
".stl" => "application/sla",
# 60
".smi" => "application/smil+xml",
".smil" => "application/smil+xml",
".xhtml" => "application/xhtml+xml",
".xht" => "application/xhtml+xml",
".xml" => "application/xml",
# 65
".xsd" => "application/xml",
".xsl" => "application/xslt+xml",
".xslt" => "application/xslt+xml",
".xspf" => "application/xspf+xml",
".zip" => "application/zip",
# 70
".apk" => "application/vnd.android.package-archive",
".cdy" => "application/vnd.cinderella",
".deb" => "application/vnd.debian.binary-package",
".ddeb" => "application/vnd.debian.binary-package",
".udeb" => "application/vnd.debian.binary-package",
# 75
".sfd" => "application/vnd.font-fontforge-sfd",
".kml" => "application/vnd.google-earth.kml+xml",
".kmz" => "application/vnd.google-earth.kmz",
".xul" => "application/vnd.mozilla.xul+xml",
".xls" => "application/vnd.ms-excel",
# 80
".xlb" => "application/vnd.ms-excel",
".xlt" => "application/vnd.ms-excel",
".eot" => "application/vnd.ms-fontobject",
".thmx" => "application/vnd.ms-officetheme",
".cat" => "application/vnd.ms-pki.seccat",
# 85
".ppt" => "application/vnd.ms-powerpoint",
".pps" => "application/vnd.ms-powerpoint",
".odc" => "application/vnd.oasis.opendocument.chart",
".odb" => "application/vnd.oasis.opendocument.database",
".odf" => "application/vnd.oasis.opendocument.formula",
# 90
".odg" => "application/vnd.oasis.opendocument.graphics",
".otg" => "application/vnd.oasis.opendocument.graphics-template",
".odi" => "application/vnd.oasis.opendocument.image",
".odp" => "application/vnd.oasis.opendocument.presentation",
".otp" => "application/vnd.oasis.opendocument.presentation-template",
# 95
".ods" => "application/vnd.oasis.opendocument.spreadsheet",
".ots" => "application/vnd.oasis.opendocument.spreadsheet-template",
".odt" => "application/vnd.oasis.opendocument.text",
".odm" => "application/vnd.oasis.opendocument.text-master",
".ott" => "application/vnd.oasis.opendocument.text-template",
# 100
".oth" => "application/vnd.oasis.opendocument.text-web",
".pptx" => "application/vnd.openxmlformats-officedocument.presentationml.presentation",
".sldx" => "application/vnd.openxmlformats-officedocument.presentationml.slide",
".ppsx" => "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
".potx" => "application/vnd.openxmlformats-officedocument.presentationml.template",
# 105
".xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
".xltx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
".docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
".dotx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
".cod" => "application/vnd.rim.cod",
# 110
".mmf" => "application/vnd.smaf",
".sdc" => "application/vnd.stardivision.calc",
".sds" => "application/vnd.stardivision.chart",
".sda" => "application/vnd.stardivision.draw",
".sdd" => "application/vnd.stardivision.impress",
# 115
".sdf" => "application/vnd.stardivision.math",
".sdw" => "application/vnd.stardivision.writer",
".sgl" => "application/vnd.stardivision.writer-global",
".sxc" => "application/vnd.sun.xml.calc",
".stc" => "application/vnd.sun.xml.calc.template",
# 120
".sxd" => "application/vnd.sun.xml.draw",
".std" => "application/vnd.sun.xml.draw.template",
".sxi" => "application/vnd.sun.xml.impress",
".sti" => "application/vnd.sun.xml.impress.template",
".sxm" => "application/vnd.sun.xml.math",
# 125
".sxw" => "application/vnd.sun.xml.writer",
".sxg" => "application/vnd.sun.xml.writer.global",
".stw" => "application/vnd.sun.xml.writer.template",
".sis" => "application/vnd.symbian.install",
".cap" => "application/vnd.tcpdump.pcap",
# 130
".pcap" => "application/vnd.tcpdump.pcap",
".vsd" => "application/vnd.visio",
".vst" => "application/vnd.visio",
".vsw" => "application/vnd.visio",
".vss" => "application/vnd.visio",
# 135
".wbxml" => "application/vnd.wap.wbxml",
".wmlc" => "application/vnd.wap.wmlc",
".wmlsc" => "application/vnd.wap.wmlscriptc",
".wpd" => "application/vnd.wordperfect",
".wp5" => "application/vnd.wordperfect5.1",
# 140
".wk" => "application/x-123",
".7z" => "application/x-7z-compressed",
".abw" => "application/x-abiword",
".dmg" => "application/x-apple-diskimage",
".bcpio" => "application/x-bcpio",
# 145
".torrent" => "application/x-bittorrent",
".cab" => "application/x-cab",
".cbr" => "application/x-cbr",
".cbz" => "application/x-cbz",
".cdf" => "application/x-cdf",
# 150
".cda" => "application/x-cdf",
".vcd" => "application/x-cdlink",
".pgn" => "application/x-chess-pgn",
".mph" => "application/x-comsol",
".cpio" => "application/x-cpio",
# 155
".csh" => "application/x-csh",
".dcr" => "application/x-director",
".dir" => "application/x-director",
".dxr" => "application/x-director",
".dms" => "application/x-dms",
# 160
".wad" => "application/x-doom",
".dvi" => "application/x-dvi",
".pfa" => "application/x-font",
".pfb" => "application/x-font",
".gsf" => "application/x-font",
# 165
".mm" => "application/x-freemind",
".gan" => "application/x-ganttproject",
".gnumeric" => "application/x-gnumeric",
".sgf" => "application/x-go-sgf",
".gcf" => "application/x-graphing-calculator",
# 170
".gtar" => "application/x-gtar",
".tgz" => "application/x-gtar-compressed",
".taz" => "application/x-gtar-compressed",
".hdf" => "application/x-hdf",
".hwp" => "application/x-hwp",
# 175
".ica" => "application/x-ica",
".info" => "application/x-info",
".ins" => "application/x-internet-signup",
".isp" => "application/x-internet-signup",
".iii" => "application/x-iphone",
# 180
".iso" => "application/x-iso9660-image",
".jam" => "application/x-jam",
".jnlp" => "application/x-java-jnlp-file",
".jmz" => "application/x-jmol",
".chrt" => "application/x-kchart",
# 185
".kil" => "application/x-killustrator",
".skp" => "application/x-koan",
".skd" => "application/x-koan",
".skt" => "application/x-koan",
".skm" => "application/x-koan",
# 190
".kpr" => "application/x-kpresenter",
".kpt" => "application/x-kpresenter",
".ksp" => "application/x-kspread",
".kwd" => "application/x-kword",
".kwt" => "application/x-kword",
# 195
".latex" => "application/x-latex",
".lha" => "application/x-lha",
".lyx" => "application/x-lyx",
".lzh" => "application/x-lzh",
".lzx" => "application/x-lzx",
# 200
".frm" => "application/x-maker",
".maker" => "application/x-maker",
".frame" => "application/x-maker",
".fm" => "application/x-maker",
".fb" => "application/x-maker",
# 205
".book" => "application/x-maker",
".fbdoc" => "application/x-maker",
".mif" => "application/x-mif",
".application" => "application/x-ms-application",
".manifest" => "application/x-ms-manifest",
# 210
".wmd" => "application/x-ms-wmd",
".wmz" => "application/x-ms-wmz",
".com" => "application/x-msdos-program",
".exe" => "application/x-msdos-program",
".bat" => "application/x-msdos-program",
# 215
".dll" => "application/x-msdos-program",
".msi" => "application/x-msi",
".nc" => "application/x-netcdf",
".pac" => "application/x-ns-proxy-autoconfig",
".nwc" => "application/x-nwc",
# 220
".o" => "application/x-object",
".oza" => "application/x-oz-application",
".p7r" => "application/x-pkcs7-certreqresp",
".crl" => "application/x-pkcs7-crl",
".pyc" => "application/x-python-code",
# 225
".pyo" => "application/x-python-code",
".qgs" => "application/x-qgis",
".shp" => "application/x-qgis",
".shx" => "application/x-qgis",
".qtl" => "application/x-quicktimeplayer",
# 230
".rdp" => "application/x-rdp",
".rpm" => "application/x-redhat-package-manager",
".rss" => "application/x-rss+xml",
".rb" => "application/x-ruby",
".sci" => "application/x-scilab",
# 235
".sce" => "application/x-scilab",
".xcos" => "application/x-scilab-xcos",
".sh" => "application/x-sh",
".shar" => "application/x-shar",
".swf" => "application/x-shockwave-flash",
# 240
".swfl" => "application/x-shockwave-flash",
".scr" => "application/x-silverlight",
".sql" => "application/x-sql",
".sit" => "application/x-stuffit",
".sitx" => "application/x-stuffit",
# 245
".sv4cpio" => "application/x-sv4cpio",
".sv4crc" => "application/x-sv4crc",
".tar" => "application/x-tar",
".tcl" => "application/x-tcl",
".gf" => "application/x-tex-gf",
# 250
".pk" => "application/x-tex-pk",
".texinfo" => "application/x-texinfo",
".texi" => "application/x-texinfo",
".t" => "application/x-troff",
".tr" => "application/x-troff",
# 255
".roff" => "application/x-troff",
".man" => "application/x-troff-man",
".me" => "application/x-troff-me",
".ms" => "application/x-troff-ms",
".ustar" => "application/x-ustar",
# 260
".src" => "application/x-wais-source",
".wz" => "application/x-wingz",
".crt" => "application/x-x509-ca-cert",
".xcf" => "application/x-xcf",
".fig" => "application/x-xfig",
# 265
".xpi" => "application/x-xpinstall",
".xz" => "application/x-xz",
".amr" => "audio/amr",
".awb" => "audio/amr-wb",
".axa" => "audio/annodex",
# 270
".au" => "audio/basic",
".snd" => "audio/basic",
".csd" => "audio/csound",
".orc" => "audio/csound",
".sco" => "audio/csound",
# 275
".flac" => "audio/flac",
".mid" => "audio/midi",
".midi" => "audio/midi",
".kar" => "audio/midi",
".mpga" => "audio/mpeg",
# 280
".mpega" => "audio/mpeg",
".mp2" => "audio/mpeg",
".mp3" => "audio/mpeg",
".m4a" => "audio/mpeg",
".m3u" => "audio/mpegurl",
# 285
".oga" => "audio/ogg",
".ogg" => "audio/ogg",
".opus" => "audio/ogg",
".spx" => "audio/ogg",
".sid" => "audio/prs.sid",
# 290
".aif" => "audio/x-aiff",
".aiff" => "audio/x-aiff",
".aifc" => "audio/x-aiff",
".gsm" => "audio/x-gsm",
".wma" => "audio/x-ms-wma",
# 295
".wax" => "audio/x-ms-wax",
".ra" => "audio/x-pn-realaudio",
".rm" => "audio/x-pn-realaudio",
".ram" => "audio/x-pn-realaudio",
".pls" => "audio/x-scpls",
# 300
".sd2" => "audio/x-sd2",
".wav" => "audio/x-wav",
".alc" => "chemical/x-alchemy",
".cac" => "chemical/x-cache",
".cache" => "chemical/x-cache",
# 305
".csf" => "chemical/x-cache-csf",
".cbin" => "chemical/x-cactvs-binary",
".cascii" => "chemical/x-cactvs-binary",
".ctab" => "chemical/x-cactvs-binary",
".cdx" => "chemical/x-cdx",
# 310
".cer" => "chemical/x-cerius",
".c3d" => "chemical/x-chem3d",
".chm" => "chemical/x-chemdraw",
".cif" => "chemical/x-cif",
".cmdf" => "chemical/x-cmdf",
# 315
".cml" => "chemical/x-cml",
".cpa" => "chemical/x-compass",
".bsd" => "chemical/x-crossfire",
".csml" => "chemical/x-csml",
".csm" => "chemical/x-csml",
# 320
".ctx" => "chemical/x-ctx",
".cxf" => "chemical/x-cxf",
".cef" => "chemical/x-cxf",
".emb" => "chemical/x-embl-dl-nucleotide",
".embl" => "chemical/x-embl-dl-nucleotide",
# 325
".spc" => "chemical/x-galactic-spc",
".inp" => "chemical/x-gamess-input",
".gam" => "chemical/x-gamess-input",
".gamin" => "chemical/x-gamess-input",
".fch" => "chemical/x-gaussian-checkpoint",
# 330
".fchk" => "chemical/x-gaussian-checkpoint",
".cub" => "chemical/x-gaussian-cube",
".gau" => "chemical/x-gaussian-input",
".gjc" => "chemical/x-gaussian-input",
".gjf" => "chemical/x-gaussian-input",
# 335
".gal" => "chemical/x-gaussian-log",
".gcg" => "chemical/x-gcg8-sequence",
".gen" => "chemical/x-genbank",
".hin" => "chemical/x-hin",
".istr" => "chemical/x-isostar",
# 340
".ist" => "chemical/x-isostar",
".jdx" => "chemical/x-jcamp-dx",
".dx" => "chemical/x-jcamp-dx",
".kin" => "chemical/x-kinemage",
".mcm" => "chemical/x-macmolecule",
# 345
".mmd" => "chemical/x-macromodel-input",
".mmod" => "chemical/x-macromodel-input",
".mol" => "chemical/x-mdl-molfile",
".rd" => "chemical/x-mdl-rdfile",
".rxn" => "chemical/x-mdl-rxnfile",
# 350
".sd" => "chemical/x-mdl-sdfile",
".tgf" => "chemical/x-mdl-tgf",
".mcif" => "chemical/x-mmcif",
".mol2" => "chemical/x-mol2",
".gpt" => "chemical/x-mopac-graph",
# 355
".mop" => "chemical/x-mopac-input",
".mopcrt" => "chemical/x-mopac-input",
".mpc" => "chemical/x-mopac-input",
".zmt" => "chemical/x-mopac-input",
".moo" => "chemical/x-mopac-out",
# 360
".mvb" => "chemical/x-mopac-vib",
".asn" => "chemical/x-ncbi-asn1",
".prt" => "chemical/x-ncbi-asn1-ascii",
".ent" => "chemical/x-ncbi-asn1-ascii",
".val" => "chemical/x-ncbi-asn1-binary",
# 365
".aso" => "chemical/x-ncbi-asn1-binary",
".pdb" => "chemical/x-pdb",
".ros" => "chemical/x-rosdal",
".sw" => "chemical/x-swissprot",
".vms" => "chemical/x-vamas-iso14976",
# 370
".vmd" => "chemical/x-vmd",
".xtel" => "chemical/x-xtel",
".xyz" => "chemical/x-xyz",
".gif" => "image/gif",
".ief" => "image/ief",
# 375
".jp2" => "image/jp2",
".jpg2" => "image/jp2",
".jpeg" => "image/jpeg",
".jpg" => "image/jpeg",
".jpe" => "image/jpeg",
# 380
".jpm" => "image/jpm",
".jpx" => "image/jpx",
".jpf" => "image/jpx",
".pcx" => "image/pcx",
".png" => "image/png",
# 385
".svg" => "image/svg+xml",
".svgz" => "image/svg+xml",
".tiff" => "image/tiff",
".tif" => "image/tiff",
".djvu" => "image/vnd.djvu",
# 390
".djv" => "image/vnd.djvu",
".ico" => "image/vnd.microsoft.icon",
".wbmp" => "image/vnd.wap.wbmp",
".cr2" => "image/x-canon-cr2",
".crw" => "image/x-canon-crw",
# 395
".ras" => "image/x-cmu-raster",
".cdr" => "image/x-coreldraw",
".pat" => "image/x-coreldrawpattern",
".cdt" => "image/x-coreldrawtemplate",
".erf" => "image/x-epson-erf",
# 400
".art" => "image/x-jg",
".jng" => "image/x-jng",
".bmp" => "image/x-ms-bmp",
".nef" => "image/x-nikon-nef",
".orf" => "image/x-olympus-orf",
# 405
".psd" => "image/x-photoshop",
".pnm" => "image/x-portable-anymap",
".pbm" => "image/x-portable-bitmap",
".pgm" => "image/x-portable-graymap",
".ppm" => "image/x-portable-pixmap",
# 410
".rgb" => "image/x-rgb",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".eml" => "message/rfc822",
# 415
".igs" => "model/iges",
".iges" => "model/iges",
".msh" => "model/mesh",
".mesh" => "model/mesh",
".silo" => "model/mesh",
# 420
".wrl" => "model/vrml",
".vrml" => "model/vrml",
".x3dv" => "model/x3d+vrml",
".x3d" => "model/x3d+xml",
".x3db" => "model/x3d+binary",
# 425
".appcache" => "text/cache-manifest",
".ics" => "text/calendar",
".icz" => "text/calendar",
".css" => "text/css",
".csv" => "text/csv",
# 430
".323" => "text/h323",
".html" => "text/html",
".htm" => "text/html",
".shtml" => "text/html",
".uls" => "text/iuls",
# 435
".mml" => "text/mathml",
".md" => "text/markdown",
".markdown" => "text/markdown",
".asc" => "text/plain",
".txt" => "text/plain",
# 440
".text" => "text/plain",
".pot" => "text/plain",
".brf" => "text/plain",
".srt" => "text/plain",
".rtx" => "text/richtext",
# 445
".sct" => "text/scriptlet",
".wsc" => "text/scriptlet",
".tm" => "text/texmacs",
".tsv" => "text/tab-separated-values",
".ttl" => "text/turtle",
# 450
".vcf" => "text/vcard",
".vcard" => "text/vcard",
".jad" => "text/vnd.sun.j2me.app-descriptor",
".wml" => "text/vnd.wap.wml",
".wmls" => "text/vnd.wap.wmlscript",
# 455
".bib" => "text/x-bibtex",
".boo" => "text/x-boo",
".h++" => "text/x-c++hdr",
".hpp" => "text/x-c++hdr",
".hxx" => "text/x-c++hdr",
# 460
".hh" => "text/x-c++hdr",
".c++" => "text/x-c++src",
".cpp" => "text/x-c++src",
".cxx" => "text/x-c++src",
".cc" => "text/x-c++src",
# 465
".h" => "text/x-chdr",
".htc" => "text/x-component",
".c" => "text/x-csrc",
".d" => "text/x-dsrc",
".diff" => "text/x-diff",
# 470
".patch" => "text/x-diff",
".hs" => "text/x-haskell",
".java" => "text/x-java",
".ly" => "text/x-lilypond",
".lhs" => "text/x-literate-haskell",
# 475
".moc" => "text/x-moc",
".p" => "text/x-pascal",
".pas" => "text/x-pascal",
".gcd" => "text/x-pcs-gcd",
".pl" => "text/x-perl",
# 480
".pm" => "text/x-perl",
".py" => "text/x-python",
".scala" => "text/x-scala",
".etx" => "text/x-setext",
".sfv" => "text/x-sfv",
# 485
".tk" => "text/x-tcl",
".tex" => "text/x-tex",
".ltx" => "text/x-tex",
".sty" => "text/x-tex",
".cls" => "text/x-tex",
# 490
".vcs" => "text/x-vcalendar",
".3gp" => "video/3gpp",
".axv" => "video/annodex",
".dl" => "video/dl",
".dif" => "video/dv",
# 495
".dv" => "video/dv",
".fli" => "video/fli",
".gl" => "video/gl",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
# 500
".mpe" => "video/mpeg",
".mp4" => "video/mp4",
".qt" => "video/quicktime",
".mov" => "video/quicktime",
".ogv" => "video/ogg",
# 505
".webm" => "video/webm",
".mxu" => "video/vnd.mpegurl",
".flv" => "video/x-flv",
".lsf" => "video/x-la-asf",
".lsx" => "video/x-la-asf",
# 510
".mng" => "video/x-mng",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wm" => "video/x-ms-wm",
".wmv" => "video/x-ms-wmv",
# 515
".wmx" => "video/x-ms-wmx",
".wvx" => "video/x-ms-wvx",
".avi" => "video/x-msvideo",
".movie" => "video/x-sgi-movie",
".mpv" => "video/x-matroska",
# 520
".mkv" => "video/x-matroska",
".ice" => "x-conference/x-cooltalk",
".sisx" => "x-epoc/x-sisx-app",
".vrm" => "x-world/x-vrml",
# 524
)
cgi.assign = (
".pl" => "/usr/bin/perl",
".py" => "/usr/bin/python",
# 2
)
}
The issue still remains. I receive a prompt to download python files instead of lighttpd executing them. Thanks for the replies.
RE: python cgi files not executing getting the static file treatment - Added by gstrauss almost 7 years ago
I receive a prompt to download python files instead of lighttpd executing them.
I'll bet that the python is being executed, but that your script response does not set Content-Type: text/html or other value, and so the browser is prompting you to save the response since it does not know the content-type.
Use curl
or wget
to see the actual lighttpd response to your request.
RE: python cgi files not executing getting the static file treatment - Added by www139 almost 7 years ago
You are correct. Updating the script to set the mimetype of the output fixed the problem.
test.py now contains:
!/usr/bin/python
print "Content-type:text/html\r\n\r\n"
print '<html>'
print '<head>'
print '<title>Hello Word - First CGI Program</title>'
print '</head>'
print '<body>'
print '<h2>Hello Word! This is my first CGI program</h2>'
print '</body>'
print '</html>'
Originally, the script contained merely print "test". I'd used that before, a while back, and it worked. It could be the browser I was using.
Thank you for the help. Sorry if this was a dumb question. It seems very obvious now lol.
RE: [Solved] python cgi files not executing getting the static file treatment - Added by gstrauss almost 7 years ago
Don't worry. You're not the only person to have done this.
Hello Word!
On the other hand, I am not sure I have seen this take before. :)