Most viewed recipes tagged "cgi" Code RecipesA very simple session handling example (Python) 2004-10-28T10:38:30-07:00Jonas Galvez <p style="color: grey"> Python recipe 325484 by <a href="/recipes/users/2122857/">Jonas Galvez</a> (<a href="/recipes/tags/cgi/">cgi</a>). Revision 4. </p> <p>This is a very simple session handling example that uses plain Python CGI (tested only under Python 2.2+). Its goal is to show how cookies are set via HTTP and how easily they can be used for session management.</p> The Simplest CGI Program (Python) 2001-03-12T06:36:58-08:00Jeff Bauer <p style="color: grey"> Python recipe 52220 by <a href="/recipes/users/98055/">Jeff Bauer</a> (<a href="/recipes/tags/cgi/">cgi</a>). </p> <p>The simplest CGI program. This script displays the current version of Python and the environment values.</p> Using a simple dictionary for CGI parameters (Python) 2001-10-13T09:51:15-07:00Richie Hindle <p style="color: grey"> Python recipe 81547 by <a href="/recipes/users/135761/">Richie Hindle</a> (<a href="/recipes/tags/cgi/">cgi</a>). </p> <p>Rather than using Python's cgi.FieldStorage class, a simple dictionary is enough for 99% of CGI scripts. This recipe shows you how to convert a FieldStorage object into a simple dictionary.</p> http - Exploring Headers and Cookies from Servers (Python) 2004-08-18T10:23:52-07:00Michael Foord <p style="color: grey"> Python recipe 298336 by <a href="/recipes/users/1565518/">Michael Foord</a> (<a href="/recipes/tags/cgi/">cgi</a>). Revision 5. </p> <p>This CGI script allows you to specify a URL. It fetches the URL and displays all the headers sent by the server. It is based on the CGI-proxy I'm building. It includes authentication circuitry and I'm using it to understand http authentication.</p> <p>This script demostrates using urllib2 to fetch a URL - using a request object with User-Agent header. It also demostrates basic authentication and shows the possible http errors - using a dictionary 'borrowed' from BaseHTTPServer.</p> <p>It will also save cookies using the ClientCookie module, if it's available.</p> Schedule Maker (Python) 2012-07-03T05:09:03-07:00Stephen Chappell <p style="color: grey"> Python recipe 475112 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/cgi/">cgi</a>). Revision 5. </p> <p>This CGI program is designed to create schedules once given valid information on a form. It is not designed to look pretty but tests the ability to combine custom modules in different sized projects. It has minimal functionality but gets its job done in a timely manner and in a format that can be understood.</p> Text Based Guest Book (Python) 2002-04-30T23:45:54-07:00Phillip Givens <p style="color: grey"> Python recipe 123894 by <a href="/recipes/users/390097/">Phillip Givens</a> (<a href="/recipes/tags/cgi/">cgi</a>). Revision 3. </p> <p>A guest book for your web page that demonstrates CGI, and file access.</p> Py Tic Tac Toe (Python) 2004-03-19T11:15:52-08:00Premshree Pillai <p style="color: grey"> Python recipe 275150 by <a href="/recipes/users/1424728/">Premshree Pillai</a> (<a href="/recipes/tags/cgi/">cgi</a>). Revision 3. </p> <p>A web-based Tic Tac Toe game in Python.</p> Paypal IPN (Python) 2006-09-19T19:02:54-07:00Anthony Barker <p style="color: grey"> Python recipe 456361 by <a href="/recipes/users/122940/">Anthony Barker</a> (<a href="/recipes/tags/cgi/">cgi</a>). Revision 2. </p> <p>This is a cgi script that allows you to log an ipn request from paypal. Basically if you configure your paypal account with an ipn url it will send a post to a script url. You need to respond with a post and then will receive a VERIFIED response.</p> <p>I've included a subroutine to log the data to a database, but you could simply use a text file if that is all you need.</p> Handling URLs within a CGI script (Python) 2001-03-19T15:29:32-08:00Jürgen Hermann <p style="color: grey"> Python recipe 52287 by <a href="/recipes/users/98061/">Jürgen Hermann</a> (<a href="/recipes/tags/cgi/">cgi</a>). </p> <p>The following are some useful functions to build URLs within a CGI script, for example to send a HTTP redirection header (see example).</p> Get user's IP address even when they're behind a proxy (Python) 2011-07-15T21:19:17-07:00Ben Hoyt <p style="color: grey"> Python recipe 577795 by <a href="/recipes/users/4170919/">Ben Hoyt</a> (<a href="/recipes/tags/address/">address</a>, <a href="/recipes/tags/cgi/">cgi</a>, <a href="/recipes/tags/ip/">ip</a>, <a href="/recipes/tags/web/">web</a>, <a href="/recipes/tags/webpy/">webpy</a>). </p> <p>Function to get the user's IP address in a web app or CGI script, even when they're behind a web proxy.</p> <p>We use as our web framework, but change web.ctx.env and web.ctx.get('ip') to whatever the equivalents are for the CGI environment variables and REMOTE_ADDR are in your framework.</p> An asynchronous HTTP server with CGI support (Python) 2007-04-05T05:46:26-07:00Pierre Quentel <p style="color: grey"> Python recipe 511454 by <a href="/recipes/users/1552957/">Pierre Quentel</a> (<a href="/recipes/tags/cgi/">cgi</a>). </p> <p>This recipes implements the HTTP protocol with persistent connection and CGI support on top of the generic asynchronous server provided in <a href="">recipe 511453</a></p> Python Sessions (Python) 2011-01-08T03:23:05-08:00Sunjay Varma <p style="color: grey"> Python recipe 577524 by <a href="/recipes/users/4174115/">Sunjay Varma</a> (<a href="/recipes/tags/cgi/">cgi</a>, <a href="/recipes/tags/cookie/">cookie</a>, <a href="/recipes/tags/management/">management</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/sessions/">sessions</a>). Revision 2. </p> <p>I think this script should now be functional enough to post here at ActiveState. When you reply or vote down, please post some information on your problem with the code, and if you can, maybe something about the solution. This interface works, and is designed especially for Python. If you like it, don't be afraid to post that either, constructive criticism is all good, but compliments are even better! ;)</p> <p>Get the latest version of this code here: <a href="" rel="nofollow"></a></p> <p><strong>Latest Changes:</strong></p> <ul> <li>Added a new function for making the session cookie last longer. See code for <code>set_expires</code>. Note: This new function is just in case you need to include a session for longer than one brower session (for example, one day instead). </li> </ul> Check web page exists (Python) 2001-12-06T18:47:01-08:00andy mckay <p style="color: grey"> Python recipe 101276 by <a href="/recipes/users/92886/">andy mckay</a> (<a href="/recipes/tags/cgi/">cgi</a>). Revision 4. </p> <p>For when you need to check a web page is still working.</p> HTML Templates (Python) 2002-08-24T05:46:00-07:00Michael Soulier <p style="color: grey"> Python recipe 146460 by <a href="/recipes/users/645856/">Michael Soulier</a> (<a href="/recipes/tags/cgi/">cgi</a>). </p> <p>This recipe consists of two classes usable for managing html templates, applicable to output from a CGI.</p> Python Script Viewer (Python) 2005-10-03T18:17:11-07:00Stephen Chappell <p style="color: grey"> Python recipe 440642 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/cgi/">cgi</a>). </p> <p>First of all, this code was written to take advantage of the custom CGI module that I wrote. The purpose for this script is to allow someone to view a CGI script through a server. I have the problem that when I click on a python (*.py) file while viewed through my browser, the script is run so that it cannot be viewed. Unless the script is using "cgi.execute(function, exception)", then there is no way of getting around the problem. Therefore, this CGI application was written so that python files (and only *.py files) can be viewed if the user knows either the filename of a file in the same directory as this script or the full path of a file somewhere on the host computer. WARNING: do not use this script if you do not want someone to view any and all python scripts on your computer!</p> Easy testing of CGI scripts (Python) 2016-11-01T02:27:13-07:00Bryan Olson <p style="color: grey"> Python recipe 550822 by <a href="/recipes/users/1998252/">Bryan Olson</a> (<a href="/recipes/tags/cgi/">cgi</a>). Revision 3. </p> <p>Invoking ' target.cgi' starts a built-in web server listening on the localhost adapter, configures the server to run target.cgi as a CGI program, then launches the system's default web browser to get the URL of the target script. The CGI script need not be in Python. The terminal that launched will show the server's log, which reports requests, responses, and errors.</p> webcounter (Python) 2004-10-15T05:33:47-07:00Michael Foord <p style="color: grey"> Python recipe 310320 by <a href="/recipes/users/1565518/">Michael Foord</a> (<a href="/recipes/tags/cgi/">cgi</a>). </p> <p>This CGI will generate a simple text 'hit counter' for several sites. Useful to ocunt visitors to the 'front door' of your website.</p> Traceback that does'nt output on sys.stderr (Python) 2001-06-25T04:25:48-07:00Dirk Holtwick <p style="color: grey"> Python recipe 65332 by <a href="/recipes/users/98196/">Dirk Holtwick</a> (<a href="/recipes/tags/cgi/">cgi</a>). </p> <p>For CGI programmers it's important to display tracebacks in the HTML pages to debug their scripts, but the usual functions in the modules cgi and traceback print to sys.sterr. So this small programm returns the traceback as a string an can even add entities for HTML.</p> "Smart" Links (Python) 2012-07-03T05:05:39-07:00Stephen Chappell <p style="color: grey"> Python recipe 440647 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/cgi/">cgi</a>). </p> <p>The following allows someone to create "smart" links on their web site. This is just a simple system and is not very advanced, but it works quite well (given its purpose). If a link is not active (because a server is down), the link is shown as such.</p> cgi-shell (Python) 2004-07-09T07:30:50-07:00Michael Foord <p style="color: grey"> Python recipe 286216 by <a href="/recipes/users/1565518/">Michael Foord</a> (<a href="/recipes/tags/cgi/">cgi</a>). </p> <p>Run an arbitrary string on the server as a shell command. Mimics a very basic shell environment on a server using CGI.</p>