Reply To: Stand-alone server: image resources fail to load

PennController for IBEX Forums Support Stand-alone server: image resources fail to load Reply To: Stand-alone server: image resources fail to load

#7703
Jeremy
Keymaster

I think you should be able to make the python script serve multimedia files from the chunk_includes folder: at lines 1573-1574 you have this:

                   if fname.endswith(".wav") or fname.endswith(".mp3") or fname.endswith("m4a"):
                        continue

This prevents the script from returning a 500 error when you request a wav/mp3/m4a file. You can allow more extensions, like this:

                    if fname.endswith(".wav") or fname.endswith(".mp3") or fname.endswith("m4a") or fname.endswith(".ogg"):
                        continue
                    if fname.endswith(".png") or fname.endswith(".jpg") or fname.endswith(".bmp"):
                        continue
                    if fname.endswith(".mp4") or fname.endswith(".webm") or fname.endswith(".ogv"):
                        continue

Then you could extend line 1615 to actually serve the content of those files when requested:

                if qs_hash['resource'][0].endswith(".wav") or qs_hash['resource'][0].endswith(".mp3") or qs_hash['resource'][0].endswith(".m4a") or qs_hash['resource'][0].endswith(".ogg"):
                    start_response('200 OK', [('Content-Type', 'audio/*'), ('Content-Length', stats.st_size)])
                elif qs_hash['resource'][0].endswith(".png") or qs_hash['resource'][0].endswith(".jpg") or qs_hash['resource'][0].endswith(".bmp"):
                    start_response('200 OK', [('Content-Type', 'image/*'), ('Content-Length', stats.st_size)])
                elif qs_hash['resource'][0].endswith(".mp4") or qs_hash['resource'][0].endswith(".webm") or qs_hash['resource'][0].endswith(".ogv"):
                    start_response('200 OK', [('Content-Type', 'video/*'), ('Content-Length', stats.st_size)])

This hack is fine as long as you run your experiment locally, but doing this for experiments that you actually run publicly on a webserver will likely cause memory overloads (we tried it on expt.pcibex.net at the time and it didn’t go well)

Jeremy