You can run Python code directly from the IVLE File Browser to try it out. You can also serve Python web applications and other files publicly.

Running

In the IVLE Editor, you can create Python scripts (.py files), which contain working programs. Often, simple programs work by printing things out (with the print statement), and reading input from the user (with the raw_input function).

You can run these programs by selecting the .py file in the File Browser, and clicking run. This will open up the Python console and display the output of the program, just as if you had typed the program into the console yourself.

For example, the following simple Python program prints a message:

print "Hello, world!"

Serving

IVLE also allows you to create web pages or web applications to show to your friends. In the IVLE Editor, you can create HTML web pages (.html files). For example, the following page contains a message:

<html><body><p>Hello, world!</p></body></html>

You can ask IVLE to serve such a file as a web page by selecting the .html file in the File Browser, and clicking serve. This will open a new tab with the web page.

You can also run a Python file as a web application in the same way. In IVLE, we use CGI to write web applications in Python, which are a little different from a normal Python script. If you serve the above script, you will see a warning, explaining that you didn't use CGI properly. An example of a simple CGI script follows:

print "Content-Type: text/html"
print
print "<html><body><p>Hello, world!</p></body></html>"

Publishing

If you wish to show your web pages and applications to the world, first, select nothing and choose publish from the "More actions" menu. This will publish the directory and all files in it to the web.

Then, select the file, and choose share this file from the "More actions" menu. This will open the file in a new tab, just like serve, except the address bar will show a "public" URL. If you give this URL to someone else (e.g., as a link in an email), they will be able to view your content.

Summary