The Internet is wonderful. You can host your application anywhere and access it anywhere! And there is no easier way to share it with friends. It isn't hard to write your own little application. The Apache Web server does all the hard networking work. Your application will print the output and it will be sent back to the browser that made the request. TI concept behind all this is the common gateway interface, or CG!, for short.
Apache in Fedora and Ubuntu is configured to handle Python cm code out:the-box-only the location where we place the code sdifferent. Let's work with the default locations because nfiguring Apache is outside the scope of this article.
In Fedora, you write your code in /var/www/cgi- in, and in Ubuntu you write it in /usr/lib/cgi-bin. The nfiguration files are in /etc/httpd in Fedora and in jete! apache2 in Ubuntu. Try the following code in hello.py.
The first line instructs the shell to run this script using Python; but the file hello.py should be executable, that is: Now, point your browser to localhost/cgi-bin/hello. rand yOlll should see 'Hello, Friends!'.



Reply With Quote
Bookmarks