Overlap
Overlap is a Cobra library that provides SCGI protocol support for applications. Applications can easily act as SCGI backend for web servers that support the protocol.
Future plans include providing WSGI and possibly FastCGI support.
What is SCGI?
SCGI stands for "Simple Common Gateway Interface". SCGI is a very lightweight and easy to parse protocol that allows any web server with SCGI support to pass requests to a separate program / application server.
Various web servers such as Apache, lighttpd and nginx have support for SCGI which allows you to have HTTP requests to the web server sent out to a program (which is often called the application server) when then returns a response, ultimately delivered to the web browser.
The communication is done via a socket and follows a particular protocol. Your program then sends an HTTP response back with headers and content (often <html> ... </html>, CSS, images, etc.).
Here is a cheap diagram:
[web browser] <--http--> [web server] <--scgi--> [app server/cobra]
With the cobra-scgi library, you can easily set up such a program/appserver in Cobra. You write a Cobra method that takes the HTTP request and returns the response as a string. Inside that method, you can do whatever you like.
So you can generate dynamic content from Cobra behind Apache and other web servers.
Sample
Here are [[sample key value pairs]] of what an SCGI-enable web server passes to the app server.
There is a sample in the repository/workspace that shows how to use the library.
Configuration
Here are general steps. Further below under "Web Servers" you may find more detailed instructions.
# Install mod_scgi for your web server if it doesn't have built-in support or does not already have the module. # Configure your web server to point a path (such as /scgi or /) to a SCGI server on a port such as 4000 or 8000. # Start your SCGI server. You can use the sample program that comes with cobra-scgi to start with. # Visit the web server via your browser.
What your browser displays should confirm that the web server passed the request to the app server which returned a response.
Web Servers
References
http://python.ca/scgi/protocol.txt
http://en.wikipedia.org/wiki/Simple_Common_Gateway_Interface
Download
Find the source code attached below.
Attachments
- Overlap.zip (4.2 KB) - added by todd.a 14 years ago.