Reply To: running penncontroller locally

PennController for IBEX Forums Support running penncontroller locally Reply To: running penncontroller locally

#2976
Jeremy
Keymaster

Hi Camilo,

Are you running you IBEX instance on Mac OS? If so, you can place your image and audio files in /Library/WebServer/Documents/ (or ~/Sites/) and then access it at, e.g. http://localhost/myImage.png. So this should work:

PennController.AddHost("http://localhost/");
PennController(
    newImage("my image", "myImage.png")
        .print()
    ,
    newButton("continue", "Continue")
        .print()
        .wait()
)

Alternatively you can edit the file server.py in your experiment’s www folder and, below these two lines:

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

add

if fname.endswith(".png") or fname.endswith(".jpg") or fname.endswith(".bmp"):
    continue

And further down, replace this line:
start_response('200 OK', [('Content-Type', 'audio/mpeg'), ('Content-Length', stats.st_size)])
with

if qs_hash['resource'][0].endswith(".wav")  or qs_hash['resource'][0].endswith(".mp3") or qs_hash['resource'][0].endswith(".m4a"):
    start_response('200 OK', [('Content-Type', 'audio/mpeg'), ('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)])

Then you can place your image and audio files (though no OGG file) in chunk_includes and do this:

PennController(
    newImage("my image", "http://localhost:3000/server.py?resource=myImage.png")
        .print()
    ,
    newButton("continue", "Continue")
        .print()
        .wait()
)