This is very similar to How to run/view web pages in the IDE, but with a couple minor tweaks and nuances.

With the latest release of the IDE, there is now a shortcut command for booting up a CGI enabled server that is accessible from the web!

All you have to do is run the following in a terminal:


This will create a cgi-bin directory in your home directory if it doesn't already exist, which will then be served on port 80 of your IDE instance. This is accessible by clicking the globe icon in the toolbar of the files tree:

or the Port 80 menu option under the View menu:

Let's drop a basic CGI script in that directory for python (let's call it ):

#!/usr/bin/env python3
print("Content-Type: text/html\n")
print("<html><body><h2>Hello World!</h2></body></html>")

Now, if you go to port 80 of your instance, and navigate to /cgi-bin/
You should see something like this:

You can add more CGI scripts to that directory, or edit this script, and you can just reload the page to see the changes!

To close the server, go back to the terminal and hit ctrl+c to cancel execution.

Remember that you can add whatever you'd like to that directory, and that it works just like a normal CGI server!

Note on Permissions 

CGI servers require certain permissions be set to access scripts/files in the cgi-bin  folder. We're currently working on ways to make this easier/more automatic, but for the time being, you may need to run the following in your terminal to get your scripts to execute correctly:

# IMPORTANT! move to the cgi-bin directory
cd ./cgi-bin/

# change the permissions of the script to 755 (rwxr-xr-x)
chmod 755 <script/executable name>

# or, you could apply permissions to the entire folder
chmod -R 755 .

# you may also want to do 777 (rwxrwxrwx)
# if you want the script to be able to read/write files in the cgi-bin dir
chmod -R 777 .
Did this answer your question?