About this project
This project attempts to perform different CGI and dynamic web operations in a variety of languages. The languages are all configured to use CGI, so we can use Apache to serve them up without a lot of extra configuration.
The project uses these languages and technologies: PHP, Perl, Python, Ruby, JavaScript, and Ajax.
The project performs these functions and activities: HTML tables and forms, server directory and file access, and MySQL database access.
How to use it
To use the project, select a language or technology from the upper list, then select an activity or function from the lower list.
The databases are live, so any changes or additions you make will be visible to other users of the site.
Languages and Technologies
PHP
PHP can present the dynamic code inline with the regular HTML. The other languages must print out all the HTML as dynamic code, or else include it from template files.
Perl, Python, Ruby
These interpreted script langauges can be used for CGI by doing these steps:
- Specify the program that runs them on the first line: e.g. #!/usr/bin/perl
- Make the script file executable
- Modify the .htaccess file to allow the pertinent file extensions to run as CGI.
JavaScript
JavaScript cannot do many server functions such as file access and database access, but it can simulate these functions using HTML5 local storage. For this reason, the JavaScript code modifies its own databases, which are indepdent of the databases used by the other server langauges.
Ajax, JSON, and XML
These are single-page applications. (SPA's). Once the home page is initially loaded, no reloads are required, even when changing views. They use HTML and JavaScript on the front end, and also a back end data server written in PHP. The data server could have been written in any of these other languages. The server generates the information unique to each view.
The Ajax version transfers the entire HTML content of the "content" div on every page change.
The JSON version transfers only the data, which is assembled into HTML content by the client. The data transferred is smaller, but more work is done on the client.
The XML version transfers only the data, which is assembled into HTML content by the client. The XML data is larger than the JXON data.
Functions and Activities
The project attempts to perform the following basic functions in each language:
- Draw a table that has dynamic data.
- Read a list of image files from a directory, and draw the images with captions.
- Read data from a file and draw it in an HTML table.
- Write data from an HTML form into the same table.
- Read data from a MySQL database and draw it in an HTML table.
- Write data from an HTML form into the same MySQL database.
This demonstrates the basic functions necessary for any web site:
- Arrays and loops
- Strings
- Forms and form handling
- Files and file permissions
- Database and MySQL access
Servers and Installation
After copying the code to a new server, the following must usually be done:
- Install the MySQL tables using the scripts in the data directory. Some adjustments to the connect scripts may be necessary.
- Compile the C++ and Java code. Some adjustments to the make scripts for C++ and Java may be necessary.
- Determine if Ruby and C# (Mono) are installed on the server. (PHP, Perl, Python, g++, and javac are usually already installed.) Some adjustments to the warnings on the Ruby and Java pages may be necessary.
Statistics
PHP files (used for Ajax server also) | 61 |
HTML files | 19 |
Python files | 14 |
Ruby files | 12 |
Perl files | 12 |
JavaScript files | 12 |
CSH files | 3 |
SQL files | 2 |
CSS files | 1 |
Total code files | 171 |