PennController for IBEX › Forums › Support › Stand-alone server: image resources fail to load
- This topic has 5 replies, 2 voices, and was last updated 2 years, 10 months ago by Jeremy.
-
AuthorPosts
-
January 19, 2022 at 8:41 am #7683cslmParticipant
Dear Jeremy,
I’m trying to set up an experiment on a stand-alone server, but the image resources keep failing to load. I’ve already moved the resources from the chunk_includes to the www directory, based on the exchange here. That ensured that the experiment doesn’t get stuck at the very beginning, but the resources still do not get loaded. The extensions are all in lowercase. Do you have an idea what could be going wrong? My Python version is 2.7.18, in case that’s relevant.
All the best,
EmielJanuary 19, 2022 at 1:04 pm #7684JeremyKeymasterDear Emiel,
Nothing comes to mind right off the bat. Feel free to share the link to your experiment either here, or at support@pcibex.net so I can take a closer look
Jeremy
January 26, 2022 at 9:51 am #7696cslmParticipantJanuary 26, 2022 at 1:24 pm #7699JeremyKeymasterHi Emiel,
That is not a link to a standalone experiment, it’s a link to an experiment on the PCIbex Farm. The resources (two images) seem to preload fine there
One thing that came to mind in the meantime: the exchange you referred to concerns running your study on a dedicated webserver. If you are running the experiment locally on your own device (eg. by typing
python server.py
in your terminal) then chances are you have no webserver running, just the server.py python script, which will not serve multimedia files from any folder. In that case, one solution would be to set up a XAMPP environment (or another webserver solution) so you can serve content at localhost:3000 (if you serve content elsewhere/on another port, then make sure to include the full URI to your files in your experiment)Jeremy
January 27, 2022 at 8:55 am #7702cslmParticipantDear Jeremy,
That explains it. Being a noob, I thought the python script would be enough to simulate a web server locally. I’ll look into your suggestion, thanks again for your help!
Best,
EmielJanuary 27, 2022 at 11:35 am #7703JeremyKeymasterI 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
-
AuthorPosts
- You must be logged in to reply to this topic.