Calling a Python Function from within a jsPsych Experiment? #2735
Replies: 1 comment
-
The basic idea here, I think, is to 1) set up a server that runs Python and 2) to send an HTTP request to run the Python code. (As your question implies, you can't really run Python in a web-browser, see here). On 1) you can use Flask to set this up and this guide should be super helpful to get you started. On 2) I recommend using the html-keyboard plugin to display a "loading" message while you perform the HTTP request (the link above contains an example how to run a JS HTTP request, but feel free to google for inspiration - also might be worth researching the security implications, I am no expert there). Make sure the page advances only if the request is successful. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi jsPsych community!
I'm working on an experiment which will query a python function every k-th trial with participant data and receive some information to then show the participant.
However, I'm having some trouble figuring out the best way to do this, as my server-side experience is limited.
Would it be recommended to set-up a server that can receive and send data to the jsPsych experiment to be retrieved from/shown to the participant (on Prolific). I'm hoping for the simplest path to get this functionality (send some data from jsPsych (a string) and retrieve some information as the output of a Python function (a string)), where the Python script would be in the local directory that I'm working out of for the experiment.
If hlepful, I am using jsPsych 6.3 and working with Pavlovia as a backend.
Thanks for any tips with this!
Beta Was this translation helpful? Give feedback.
All reactions