Stand-alone server: image resources fail to load

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

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #7683
    cslm
    Participant

    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,
    Emiel

    #7684
    Jeremy
    Keymaster

    Dear 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

    #7696
    cslm
    Participant

    Hi Jeremy,

    Thanks for your reply. Here’s a link to the experiment.

    Emiel

    #7699
    Jeremy
    Keymaster

    Hi 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

    #7702
    cslm
    Participant

    Dear 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,
    Emiel

    #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

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.