2
<p>You can <strong>run</strong> Python code directly from the IVLE File
3
Browser to try it out. You can also <strong>serve</strong> Python web
4
applications and other files publicly.</p>
8
<p>In the IVLE Editor, you can create Python scripts (<strong>.py</strong>
9
files), which contain working programs. Often, simple programs work by
10
printing things out (with the <strong>print</strong> statement), and reading
11
input from the user (with the <strong>raw_input</strong> function).</p>
13
<p>You can run these programs by selecting the <strong>.py</strong> file in
14
the File Browser, and clicking <strong>run</strong>. This will open up the
15
Python console and display the output of the program, just as if you had typed
16
the program into the console yourself.</p>
18
<p>For example, the following simple Python program prints a message:</p>
20
<pre>print "Hello, world!"</pre>
24
<p>IVLE also allows you to create web pages or web applications to show to
25
your friends. In the IVLE Editor, you can create HTML web pages
26
(<strong>.html</strong> files). For example, the following page contains a
29
<pre><html><body><p>Hello, world!</p></body></html></pre>
31
<p>You can ask IVLE to serve such a file as a web page by selecting the
32
<strong>.html</strong> file in the File Browser, and clicking
33
<strong>serve</strong>. This will open a new tab with the web page.</p>
35
<p>You can also run a Python file as a web application in the same way. In
36
IVLE, we use CGI to write web applications in Python, which are a little
37
different from a normal Python script. If you serve the above script, you will
38
see a warning, explaining that you didn't use CGI properly. An example of a
39
simple CGI script follows:</p>
41
<pre>print "Content-Type: text/html"
43
print "<html><body><p>Hello, world!</p></body></html>"</pre>
47
<p>If you wish to show your web pages and applications to the world, first,
48
select nothing and choose <strong>publish</strong> from the "More actions"
49
menu. This will <em>publish</em> the directory and all files in it to the
52
<p>Then, select the file, and choose <strong>share this file</strong> from the
53
"More actions" menu. This will open the file in a new tab, just like
54
<strong>serve</strong>, except the address bar will show a "public" URL. If
55
you give this URL to someone else (e.g., as a link in an email), they will be
56
able to view your content.</p>
60
<li><strong>Run</strong> runs Python programs as command-line applications.</li>
61
<li><strong>Serve</strong> runs Python programs as CGI applications, showing their web output.</li>
62
<li><strong>Publish</strong> lets other people view your web pages and CGI applications as if they were <strong>served</strong>.</li>