This tutorial assumes that you have a basic knowledge of the Xitami web server and the Euphoria programming language, as well as a familiarity with CGI programming. If this is not true for you, be warned that some of the following tutorial may be harder to understand. The tutorial is based on a system using Xitami version 2.5c2 and Euphoria version 3.1 on a computer running Windows XP SP2. Your system should use a similar or newer configuration.
Set up the Xitami Server
The first step is to set up Xitami to recognize Euphoria programs. This is done by setting up filters. Go to the web-based Xitami control panel and select the Configuration option. From there, select the Filters page from the navigation links along the top.
Set up one or more new filters using the file extensions that you want to use for Euphoria files. In my example, I have used the default Euphoria extensions of .ex and .exw. The filters must point to the processor program EXWC, which runs as a Windows program in console mode. The other processors (EX and EXW) do not work correctly with Xitami. Make sure you save your configuration after adding the new filters.
While you are in the control panel, check the CGI page to ensure that your CGI options are set correctly. The options "CGI enabled" and "Use standard I/O" must both be checked.
Restart your web server after making these changes. Once the server has started back up, it will be ready to process Euphoria programs.
Write a Euphoria CGI Program
See the sample program I have provided to get an idea of how to work with CGI in Euphoria. This program accepts data sent with the GET method and displays the method and the data on the web page.
Use the getenv() command to find your variables. There are a whole range of environment variables available to a CGI program, but the two most important are REQUEST_METHOD and QUERY_STRING. These will allow you to get the data (if any) that was passed to your program.
If your program was called via the GET method, your variables will be in the environment variable QUERY_STRING. If it was called using the POST method, your variables will be in the standard input (file 0) instead. (If you check the standard input when the program was called with GET, you will find the source code for your program.)
The data that goes back to the user is written to the standard output (file 1) as you would expect. Make sure that whatever output you create contains proper HTTP headers and a blank line separating the headers from the actual output.
Start with the sample program I've provided. Place the program in your webpage directory and call it from your web browser. You should see the values of the REQUEST_METHOD and QUERY_STRING printed on the page. If not, make sure that you have entered the program exactly as provided, all of the Xitami settings are correct, and the web server was restarted after making changes.
Once you have it working, you can expand the program to do whatever you have in mind. You will soon find that Euphoria's simple data handling and powerful abilities are well suited to CGI processing.
Published by Mike Wever
Mike Wever is a computer expert, sometimes video producer, and editor of a small press magazine called Wanderings. View profile
- Free Children's Entertainment in the Research TriangleThe good news is that the Triangle offers lots of choices for a day's play. Here are some of the favorite, free hang-outs of Triangle parents.
- 5 Free Ways to Clean Up Your ComputerWhether it's a virus, spyware, grayware, or other creepy-crawly in your computer thats making it act slow and sluggish, these 5 free programs are easy to download and install to fix the malady.
- Download and Play Dofus for Free Online - A Fun MMORPGIf you are looking for a Massively Multiplayer Online Roleplaying game (MMORPG) that the whole family can enjoy, head on over to Dofus. com and download the free client for this insanely cute French game.
- The Complexities of the Aging ProcessSome of the theories describe aging as a positive process that one can look forward to, whereas other theories describe aging as a series of ongoing conflicts that need to be resolved.
- WHAT'S YOUR PROCESS?Your marketing must consist of a smooth process that leads people step by step from leads to prospects to customers to clients to referral sources using a series of soft steps that build trust and relationships.
- Get Free Trees to Plant for Arbor Day
- Finding Free Online Birthday Cards
- Get Free Patterns Online
- Does a Free Credit Report Include All Three Credit Scores?
- St. Louis - Gateway to the West...and Free Stuff!
- Free WiFi from Nintendo?
- Free Programs for Windows




