Creating Embedded Python Consoles

Here are the steps for embedding a Python console (from PythonAnywhere, at present) inside a web page for one of our courses, or otherwise.

  1. Create a gist on GitHub by copying in the module you want the students to run from the main repo (or elsewhere).
  2. From the gist repo copy the URL of the gist.
  3. Modify ptml file to include python_anywhere.txt at the place you want the console to appear. This file exists in the algorithms/templates directory.
  4. Include instruction for how to load and run the code in python console.
    Here is a sample of what sort of instructions you need:
              
        !git clone https://gist.github.com/25ffc0600a866535adef05c5d8eca34a.git 
        cd 25ffc0600a866535adef05c5d8eca34a 
        from find_max_subarray import * 
        A = [13, -3, -25, 20, -3, -16, -23, 18, 20, -7, 12, -5, -22, 15, -4, 7] 
              
              
  5. Use sample data from the textbook on the web page.
  6. Test, test, test