@@ -27,11 +27,62 @@ Using this application, teachers and students can write small Python
2727code snippets together and see what happens to the data structures when
2828the code gets executed.
2929
30- ---
31-
3230Try it out live at: http://people.csail.mit.edu/pgbovine/python/
3331
34- ---
32+ ======
33+ System architecture overview:
34+
35+ The Online Python Tutor is implemented as a web application, with a
36+ JavaScript front-end making AJAX calls to a pure-Python back-end.
37+
38+ The back-end has been tested on an Apache server running Python 2.5
39+ through CGI. Note that it will probably fail in subtle ways on other
40+ Python 2.X (and will DEFINITELY fail on Python 3.X). Peter Wentworth
41+ has create a port to Python 3.X, and hopefully we can soon integrate his
42+ code into my repository.
43+
44+
45+ The front-end is HTML/javascript (using the jQuery library). It's
46+ responsible for the input text box, submitting the Python code (as
47+ plaintext) to the back-end, receiving an execution trace from the
48+ back-end, and then rendering that trace as data structure
49+ visualizations. The front-end code is publicly available in these 5
50+ files in the current directory:
51+
52+ index.html
53+ edu-python.js
54+ edu-python.css
55+ jquery-1.3.2.min.js
56+ jquery.textarea.js
57+
58+
59+ The back-end is a server-side app that takes Python script source code
60+ as input, executes the entire script (up to 100 executed lines, to
61+ prevent infinite loops), and collects a full trace of all variable
62+ values (i.e., data structures) after each line is executed. It then
63+ sends that complete trace to the front-end in an encoded JSON format.
64+ The front-end then parses that trace, which is how it's able to
65+ single-step forwards AND backwards through execution.
66+
67+ The back-end files reside in the cgi-bin/ sub-directory in this
68+ repository:
69+
70+ cgi-bin/web_exec.py - the CGI entrance point to the back-end
71+ cgi-bin/pg_logger.py - the 'meat' of the back-end
72+ cgi-bin/pg_encoder.py - encodes Python data into JSON
73+ cgi-bin/demjson.py - 3rd-party JSON module, since Python 2.5
74+ - doesn't have the built-in 'import json'
75+ cgi-bin/create_db.py - for optional sqlite query logging
76+ cgi-bin/db_common.py - for optional sqlite query logging
77+ cgi-bin/.htaccess - for Apache CGI execute permissions
78+ cgi-bin/run_tests.py - simple regression tests
79+
80+
81+ Due to the AJAX same-origin policy, the front-end and back-end must be
82+ deployed on the same server (unless you do some fancy proxy magic).
83+
84+
85+ ======
3586Original vision (from January 2010):
3687
3788I want to create a web-based interactive learning platform for students
@@ -64,43 +115,3 @@ The PDB debugger (Lib/pdb.py) is written in pure Python:
64115 - the bdb debugger framework is the C module that pdb calls
65116 http://docs.python.org/library/bdb.html
66117
67- ---
68-
69- Informal system architecture overview --- sent in an email on 2010-09-05
70-
71- '''
72- i'll give you a bit of background on the architecture of the system:
73-
74- 1.) The front-end is HTML/javascript (using the jQuery library) ... it's
75- responsible for the input text box, submitting the Python code (as
76- plaintext) to the backend, receiving an execution trace from the
77- backend, and then rendering that trace as data structure visualizations.
78- all the front-end code is already publicly available in these 5 files:
79-
80- http://people.csail.mit.edu/pgbovine/python/index.html
81- http://people.csail.mit.edu/pgbovine/python/jquery-1.3.2.min.js
82- http://people.csail.mit.edu/pgbovine/python/jquery.textarea.js
83- http://people.csail.mit.edu/pgbovine/python/edu-python.js
84- http://people.csail.mit.edu/pgbovine/python/edu-python.css
85-
86-
87- 2.) The back-end is a server-side app that takes Python script source
88- code as input, executes the entire script (up to 100 executed lines, to
89- prevent infinite loops), and collects a full trace of all variable
90- values after each line is executed. It then sends that trace to the
91- front-end in an encoded JSON format. The front-end then parses that
92- trace, which is how it's able to single-step forwards AND backwards
93- through execution.
94-
95- The back-end currently runs on my server, and I think the most
96- convenient thing to do right now is to simply invoke it as a web
97- service. This is the URL:
98-
99- http://people.csail.mit.edu/pgbovine/python/cgi-bin/web_exec.py
100-
101- and it expects only ONE following parameter to be passed in via POST.
102- that parameter is called 'user_script', and it's a string that contains
103- the text of the script to be executed. so the interface is pretty
104- simple ;)
105- '''
106-
0 commit comments